
_sh:     file format elf32-i386


Disassembly of section .text:

00000000 <nulterminate>:
}

// NUL-terminate all the counted strings.
struct cmd*
nulterminate(struct cmd *cmd)
{
       0:	55                   	push   %ebp
       1:	89 e5                	mov    %esp,%ebp
       3:	53                   	push   %ebx
       4:	83 ec 14             	sub    $0x14,%esp
       7:	8b 5d 08             	mov    0x8(%ebp),%ebx
  struct execcmd *ecmd;
  struct listcmd *lcmd;
  struct pipecmd *pcmd;
  struct redircmd *rcmd;

  if(cmd == 0)
       a:	85 db                	test   %ebx,%ebx
       c:	74 05                	je     13 <nulterminate+0x13>
    return 0;
  
  switch(cmd->type){
       e:	83 3b 05             	cmpl   $0x5,(%ebx)
      11:	76 0d                	jbe    20 <nulterminate+0x20>
    bcmd = (struct backcmd*)cmd;
    nulterminate(bcmd->cmd);
    break;
  }
  return cmd;
}
      13:	89 d8                	mov    %ebx,%eax
      15:	83 c4 14             	add    $0x14,%esp
      18:	5b                   	pop    %ebx
      19:	5d                   	pop    %ebp
      1a:	c3                   	ret    
      1b:	90                   	nop
      1c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  struct redircmd *rcmd;

  if(cmd == 0)
    return 0;
  
  switch(cmd->type){
      20:	8b 03                	mov    (%ebx),%eax
      22:	ff 24 85 e0 15 00 00 	jmp    *0x15e0(,%eax,4)
      29:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    nulterminate(pcmd->right);
    break;
    
  case LIST:
    lcmd = (struct listcmd*)cmd;
    nulterminate(lcmd->left);
      30:	8b 43 04             	mov    0x4(%ebx),%eax
      33:	89 04 24             	mov    %eax,(%esp)
      36:	e8 c5 ff ff ff       	call   0 <nulterminate>
    nulterminate(lcmd->right);
      3b:	8b 43 08             	mov    0x8(%ebx),%eax
      3e:	89 04 24             	mov    %eax,(%esp)
      41:	e8 ba ff ff ff       	call   0 <nulterminate>
    bcmd = (struct backcmd*)cmd;
    nulterminate(bcmd->cmd);
    break;
  }
  return cmd;
}
      46:	89 d8                	mov    %ebx,%eax
      48:	83 c4 14             	add    $0x14,%esp
      4b:	5b                   	pop    %ebx
      4c:	5d                   	pop    %ebp
      4d:	c3                   	ret    
      4e:	66 90                	xchg   %ax,%ax
    nulterminate(lcmd->right);
    break;

  case BACK:
    bcmd = (struct backcmd*)cmd;
    nulterminate(bcmd->cmd);
      50:	8b 43 04             	mov    0x4(%ebx),%eax
      53:	89 04 24             	mov    %eax,(%esp)
      56:	e8 a5 ff ff ff       	call   0 <nulterminate>
    break;
  }
  return cmd;
}
      5b:	89 d8                	mov    %ebx,%eax
      5d:	83 c4 14             	add    $0x14,%esp
      60:	5b                   	pop    %ebx
      61:	5d                   	pop    %ebp
      62:	c3                   	ret    
      63:	90                   	nop
      64:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
      *ecmd->eargv[i] = 0;
    break;

  case REDIR:
    rcmd = (struct redircmd*)cmd;
    nulterminate(rcmd->cmd);
      68:	8b 43 04             	mov    0x4(%ebx),%eax
      6b:	89 04 24             	mov    %eax,(%esp)
      6e:	e8 8d ff ff ff       	call   0 <nulterminate>
    *rcmd->efile = 0;
      73:	8b 43 0c             	mov    0xc(%ebx),%eax
      76:	c6 00 00             	movb   $0x0,(%eax)
    bcmd = (struct backcmd*)cmd;
    nulterminate(bcmd->cmd);
    break;
  }
  return cmd;
}
      79:	89 d8                	mov    %ebx,%eax
      7b:	83 c4 14             	add    $0x14,%esp
      7e:	5b                   	pop    %ebx
      7f:	5d                   	pop    %ebp
      80:	c3                   	ret    
      81:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    return 0;
  
  switch(cmd->type){
  case EXEC:
    ecmd = (struct execcmd*)cmd;
    for(i=0; ecmd->argv[i]; i++)
      88:	8b 43 04             	mov    0x4(%ebx),%eax
      8b:	85 c0                	test   %eax,%eax
      8d:	74 84                	je     13 <nulterminate+0x13>
      8f:	89 d8                	mov    %ebx,%eax
      91:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
      *ecmd->eargv[i] = 0;
      98:	8b 50 2c             	mov    0x2c(%eax),%edx
      9b:	c6 02 00             	movb   $0x0,(%edx)
    return 0;
  
  switch(cmd->type){
  case EXEC:
    ecmd = (struct execcmd*)cmd;
    for(i=0; ecmd->argv[i]; i++)
      9e:	8b 50 08             	mov    0x8(%eax),%edx
      a1:	83 c0 04             	add    $0x4,%eax
      a4:	85 d2                	test   %edx,%edx
      a6:	75 f0                	jne    98 <nulterminate+0x98>
    bcmd = (struct backcmd*)cmd;
    nulterminate(bcmd->cmd);
    break;
  }
  return cmd;
}
      a8:	89 d8                	mov    %ebx,%eax
      aa:	83 c4 14             	add    $0x14,%esp
      ad:	5b                   	pop    %ebx
      ae:	5d                   	pop    %ebp
      af:	c3                   	ret    

000000b0 <copyComm>:
static char paths[MAXDIRS][MAXPATHSNAMES];
static int numOfDirs = 0;
char EmptyLine[] = "\n";
static char tempComm[128];

void copyComm(char * orig, int path){
      b0:	55                   	push   %ebp
      b1:	89 e5                	mov    %esp,%ebp
      b3:	57                   	push   %edi
      b4:	56                   	push   %esi
      b5:	53                   	push   %ebx
      b6:	31 db                	xor    %ebx,%ebx
      b8:	83 ec 2c             	sub    $0x2c,%esp
      bb:	8b 45 0c             	mov    0xc(%ebp),%eax
      be:	8b 7d 08             	mov    0x8(%ebp),%edi
      c1:	8d 04 80             	lea    (%eax,%eax,4),%eax
      c4:	8d 04 85 a0 17 00 00 	lea    0x17a0(,%eax,4),%eax
      cb:	89 45 e4             	mov    %eax,-0x1c(%ebp)
      ce:	89 c6                	mov    %eax,%esi
	int i;
	int j;
	for (i=0; i<strlen(paths[path]) ; i++){
      d0:	eb 15                	jmp    e7 <copyComm+0x37>
      d2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
		tempComm[i] = paths[path][i];
      d8:	0f b6 06             	movzbl (%esi),%eax
static char tempComm[128];

void copyComm(char * orig, int path){
	int i;
	int j;
	for (i=0; i<strlen(paths[path]) ; i++){
      db:	83 c6 01             	add    $0x1,%esi
		tempComm[i] = paths[path][i];
      de:	88 83 40 19 00 00    	mov    %al,0x1940(%ebx)
static char tempComm[128];

void copyComm(char * orig, int path){
	int i;
	int j;
	for (i=0; i<strlen(paths[path]) ; i++){
      e4:	83 c3 01             	add    $0x1,%ebx
      e7:	8b 45 e4             	mov    -0x1c(%ebp),%eax
      ea:	89 04 24             	mov    %eax,(%esp)
      ed:	e8 6e 0e 00 00       	call   f60 <strlen>
      f2:	39 d8                	cmp    %ebx,%eax
      f4:	77 e2                	ja     d8 <copyComm+0x28>
		tempComm[i] = paths[path][i];
	}
	j=0;
	
	tempComm[strlen(paths[path])] = '/';
      f6:	8b 45 e4             	mov    -0x1c(%ebp),%eax
	for (i=strlen(paths[path])+1; j<strlen(orig); i++){
      f9:	31 db                	xor    %ebx,%ebx
	for (i=0; i<strlen(paths[path]) ; i++){
		tempComm[i] = paths[path][i];
	}
	j=0;
	
	tempComm[strlen(paths[path])] = '/';
      fb:	89 04 24             	mov    %eax,(%esp)
      fe:	e8 5d 0e 00 00       	call   f60 <strlen>
     103:	c6 80 40 19 00 00 2f 	movb   $0x2f,0x1940(%eax)
	for (i=strlen(paths[path])+1; j<strlen(orig); i++){
     10a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
     10d:	89 04 24             	mov    %eax,(%esp)
     110:	e8 4b 0e 00 00       	call   f60 <strlen>
     115:	8d b0 41 19 00 00    	lea    0x1941(%eax),%esi
     11b:	eb 0f                	jmp    12c <copyComm+0x7c>
     11d:	8d 76 00             	lea    0x0(%esi),%esi
		tempComm[i] = orig[j];
     120:	0f b6 04 1f          	movzbl (%edi,%ebx,1),%eax
		j = j + 1;
     124:	83 c3 01             	add    $0x1,%ebx
	}
	j=0;
	
	tempComm[strlen(paths[path])] = '/';
	for (i=strlen(paths[path])+1; j<strlen(orig); i++){
		tempComm[i] = orig[j];
     127:	88 06                	mov    %al,(%esi)
		j = j + 1;
     129:	83 c6 01             	add    $0x1,%esi
		tempComm[i] = paths[path][i];
	}
	j=0;
	
	tempComm[strlen(paths[path])] = '/';
	for (i=strlen(paths[path])+1; j<strlen(orig); i++){
     12c:	89 3c 24             	mov    %edi,(%esp)
     12f:	e8 2c 0e 00 00       	call   f60 <strlen>
     134:	39 c3                	cmp    %eax,%ebx
     136:	72 e8                	jb     120 <copyComm+0x70>
		tempComm[i] = orig[j];
		j = j + 1;
	}
	
}
     138:	83 c4 2c             	add    $0x2c,%esp
     13b:	5b                   	pop    %ebx
     13c:	5e                   	pop    %esi
     13d:	5f                   	pop    %edi
     13e:	5d                   	pop    %ebp
     13f:	c3                   	ret    

00000140 <printTest>:
  close(pEnvFile);
}

void
printTest(void)
{
     140:	55                   	push   %ebp
     141:	89 e5                	mov    %esp,%ebp
     143:	83 ec 18             	sub    $0x18,%esp
	printf(1,paths[0]); printf(1, EmptyLine);
     146:	c7 44 24 04 a0 17 00 	movl   $0x17a0,0x4(%esp)
     14d:	00 
     14e:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
     155:	e8 06 11 00 00       	call   1260 <printf>
     15a:	c7 44 24 04 08 17 00 	movl   $0x1708,0x4(%esp)
     161:	00 
     162:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
     169:	e8 f2 10 00 00       	call   1260 <printf>
	printf(1,paths[1]); printf(1, EmptyLine);
     16e:	c7 44 24 04 b4 17 00 	movl   $0x17b4,0x4(%esp)
     175:	00 
     176:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
     17d:	e8 de 10 00 00       	call   1260 <printf>
     182:	c7 44 24 04 08 17 00 	movl   $0x1708,0x4(%esp)
     189:	00 
     18a:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
     191:	e8 ca 10 00 00       	call   1260 <printf>
	printf(1,paths[2]); printf(1, EmptyLine);
     196:	c7 44 24 04 c8 17 00 	movl   $0x17c8,0x4(%esp)
     19d:	00 
     19e:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
     1a5:	e8 b6 10 00 00       	call   1260 <printf>
     1aa:	c7 44 24 04 08 17 00 	movl   $0x1708,0x4(%esp)
     1b1:	00 
     1b2:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
     1b9:	e8 a2 10 00 00       	call   1260 <printf>
}
     1be:	c9                   	leave  
     1bf:	c3                   	ret    

000001c0 <peek>:
  return ret;
}

int
peek(char **ps, char *es, char *toks)
{
     1c0:	55                   	push   %ebp
     1c1:	89 e5                	mov    %esp,%ebp
     1c3:	57                   	push   %edi
     1c4:	56                   	push   %esi
     1c5:	53                   	push   %ebx
     1c6:	83 ec 1c             	sub    $0x1c,%esp
     1c9:	8b 7d 08             	mov    0x8(%ebp),%edi
     1cc:	8b 75 0c             	mov    0xc(%ebp),%esi
  char *s;
  
  s = *ps;
     1cf:	8b 1f                	mov    (%edi),%ebx
  while(s < es && strchr(whitespace, *s))
     1d1:	39 f3                	cmp    %esi,%ebx
     1d3:	72 0a                	jb     1df <peek+0x1f>
     1d5:	eb 1f                	jmp    1f6 <peek+0x36>
     1d7:	90                   	nop
    s++;
     1d8:	83 c3 01             	add    $0x1,%ebx
peek(char **ps, char *es, char *toks)
{
  char *s;
  
  s = *ps;
  while(s < es && strchr(whitespace, *s))
     1db:	39 de                	cmp    %ebx,%esi
     1dd:	76 17                	jbe    1f6 <peek+0x36>
     1df:	0f be 03             	movsbl (%ebx),%eax
     1e2:	c7 04 24 0a 17 00 00 	movl   $0x170a,(%esp)
     1e9:	89 44 24 04          	mov    %eax,0x4(%esp)
     1ed:	e8 ae 0d 00 00       	call   fa0 <strchr>
     1f2:	85 c0                	test   %eax,%eax
     1f4:	75 e2                	jne    1d8 <peek+0x18>
    s++;
  *ps = s;
     1f6:	89 1f                	mov    %ebx,(%edi)
  return *s && strchr(toks, *s);
     1f8:	0f b6 13             	movzbl (%ebx),%edx
     1fb:	31 c0                	xor    %eax,%eax
     1fd:	84 d2                	test   %dl,%dl
     1ff:	75 0f                	jne    210 <peek+0x50>
}
     201:	83 c4 1c             	add    $0x1c,%esp
     204:	5b                   	pop    %ebx
     205:	5e                   	pop    %esi
     206:	5f                   	pop    %edi
     207:	5d                   	pop    %ebp
     208:	c3                   	ret    
     209:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  
  s = *ps;
  while(s < es && strchr(whitespace, *s))
    s++;
  *ps = s;
  return *s && strchr(toks, *s);
     210:	0f be d2             	movsbl %dl,%edx
     213:	89 54 24 04          	mov    %edx,0x4(%esp)
     217:	8b 45 10             	mov    0x10(%ebp),%eax
     21a:	89 04 24             	mov    %eax,(%esp)
     21d:	e8 7e 0d 00 00       	call   fa0 <strchr>
     222:	85 c0                	test   %eax,%eax
     224:	0f 95 c0             	setne  %al
}
     227:	83 c4 1c             	add    $0x1c,%esp
  
  s = *ps;
  while(s < es && strchr(whitespace, *s))
    s++;
  *ps = s;
  return *s && strchr(toks, *s);
     22a:	0f b6 c0             	movzbl %al,%eax
}
     22d:	5b                   	pop    %ebx
     22e:	5e                   	pop    %esi
     22f:	5f                   	pop    %edi
     230:	5d                   	pop    %ebp
     231:	c3                   	ret    
     232:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
     239:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000240 <gettoken>:
char whitespace[] = " \t\r\n\v";
char symbols[] = "<|>&;()";

int
gettoken(char **ps, char *es, char **q, char **eq)
{
     240:	55                   	push   %ebp
     241:	89 e5                	mov    %esp,%ebp
     243:	57                   	push   %edi
     244:	56                   	push   %esi
     245:	53                   	push   %ebx
     246:	83 ec 1c             	sub    $0x1c,%esp
  char *s;
  int ret;
  
  s = *ps;
     249:	8b 45 08             	mov    0x8(%ebp),%eax
char whitespace[] = " \t\r\n\v";
char symbols[] = "<|>&;()";

int
gettoken(char **ps, char *es, char **q, char **eq)
{
     24c:	8b 75 0c             	mov    0xc(%ebp),%esi
     24f:	8b 7d 10             	mov    0x10(%ebp),%edi
  char *s;
  int ret;
  
  s = *ps;
     252:	8b 18                	mov    (%eax),%ebx
  while(s < es && strchr(whitespace, *s))
     254:	39 f3                	cmp    %esi,%ebx
     256:	72 0f                	jb     267 <gettoken+0x27>
     258:	eb 24                	jmp    27e <gettoken+0x3e>
     25a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    s++;
     260:	83 c3 01             	add    $0x1,%ebx
{
  char *s;
  int ret;
  
  s = *ps;
  while(s < es && strchr(whitespace, *s))
     263:	39 de                	cmp    %ebx,%esi
     265:	76 17                	jbe    27e <gettoken+0x3e>
     267:	0f be 03             	movsbl (%ebx),%eax
     26a:	c7 04 24 0a 17 00 00 	movl   $0x170a,(%esp)
     271:	89 44 24 04          	mov    %eax,0x4(%esp)
     275:	e8 26 0d 00 00       	call   fa0 <strchr>
     27a:	85 c0                	test   %eax,%eax
     27c:	75 e2                	jne    260 <gettoken+0x20>
    s++;
  if(q)
     27e:	85 ff                	test   %edi,%edi
     280:	74 02                	je     284 <gettoken+0x44>
    *q = s;
     282:	89 1f                	mov    %ebx,(%edi)
  ret = *s;
     284:	0f b6 13             	movzbl (%ebx),%edx
     287:	0f be fa             	movsbl %dl,%edi
  switch(*s){
     28a:	80 fa 3c             	cmp    $0x3c,%dl
  s = *ps;
  while(s < es && strchr(whitespace, *s))
    s++;
  if(q)
    *q = s;
  ret = *s;
     28d:	89 f8                	mov    %edi,%eax
  switch(*s){
     28f:	7f 4f                	jg     2e0 <gettoken+0xa0>
     291:	80 fa 3b             	cmp    $0x3b,%dl
     294:	0f 8c a6 00 00 00    	jl     340 <gettoken+0x100>
  case '(':
  case ')':
  case ';':
  case '&':
  case '<':
    s++;
     29a:	83 c3 01             	add    $0x1,%ebx
    ret = 'a';
    while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
      s++;
    break;
  }
  if(eq)
     29d:	8b 55 14             	mov    0x14(%ebp),%edx
     2a0:	85 d2                	test   %edx,%edx
     2a2:	74 05                	je     2a9 <gettoken+0x69>
    *eq = s;
     2a4:	8b 45 14             	mov    0x14(%ebp),%eax
     2a7:	89 18                	mov    %ebx,(%eax)
  
  while(s < es && strchr(whitespace, *s))
     2a9:	39 f3                	cmp    %esi,%ebx
     2ab:	72 0a                	jb     2b7 <gettoken+0x77>
     2ad:	eb 1f                	jmp    2ce <gettoken+0x8e>
     2af:	90                   	nop
    s++;
     2b0:	83 c3 01             	add    $0x1,%ebx
    break;
  }
  if(eq)
    *eq = s;
  
  while(s < es && strchr(whitespace, *s))
     2b3:	39 de                	cmp    %ebx,%esi
     2b5:	76 17                	jbe    2ce <gettoken+0x8e>
     2b7:	0f be 03             	movsbl (%ebx),%eax
     2ba:	c7 04 24 0a 17 00 00 	movl   $0x170a,(%esp)
     2c1:	89 44 24 04          	mov    %eax,0x4(%esp)
     2c5:	e8 d6 0c 00 00       	call   fa0 <strchr>
     2ca:	85 c0                	test   %eax,%eax
     2cc:	75 e2                	jne    2b0 <gettoken+0x70>
    s++;
  *ps = s;
     2ce:	8b 45 08             	mov    0x8(%ebp),%eax
     2d1:	89 18                	mov    %ebx,(%eax)
  return ret;
}
     2d3:	83 c4 1c             	add    $0x1c,%esp
     2d6:	89 f8                	mov    %edi,%eax
     2d8:	5b                   	pop    %ebx
     2d9:	5e                   	pop    %esi
     2da:	5f                   	pop    %edi
     2db:	5d                   	pop    %ebp
     2dc:	c3                   	ret    
     2dd:	8d 76 00             	lea    0x0(%esi),%esi
  while(s < es && strchr(whitespace, *s))
    s++;
  if(q)
    *q = s;
  ret = *s;
  switch(*s){
     2e0:	80 fa 3e             	cmp    $0x3e,%dl
     2e3:	0f 84 7f 00 00 00    	je     368 <gettoken+0x128>
     2e9:	80 fa 7c             	cmp    $0x7c,%dl
     2ec:	74 ac                	je     29a <gettoken+0x5a>
      s++;
    }
    break;
  default:
    ret = 'a';
    while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
     2ee:	39 de                	cmp    %ebx,%esi
     2f0:	77 2f                	ja     321 <gettoken+0xe1>
     2f2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
     2f8:	eb 3b                	jmp    335 <gettoken+0xf5>
     2fa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
     300:	0f be 03             	movsbl (%ebx),%eax
     303:	c7 04 24 10 17 00 00 	movl   $0x1710,(%esp)
     30a:	89 44 24 04          	mov    %eax,0x4(%esp)
     30e:	e8 8d 0c 00 00       	call   fa0 <strchr>
     313:	85 c0                	test   %eax,%eax
     315:	75 1e                	jne    335 <gettoken+0xf5>
      s++;
     317:	83 c3 01             	add    $0x1,%ebx
      s++;
    }
    break;
  default:
    ret = 'a';
    while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
     31a:	39 de                	cmp    %ebx,%esi
     31c:	76 17                	jbe    335 <gettoken+0xf5>
     31e:	0f be 03             	movsbl (%ebx),%eax
     321:	89 44 24 04          	mov    %eax,0x4(%esp)
     325:	c7 04 24 0a 17 00 00 	movl   $0x170a,(%esp)
     32c:	e8 6f 0c 00 00       	call   fa0 <strchr>
     331:	85 c0                	test   %eax,%eax
     333:	74 cb                	je     300 <gettoken+0xc0>
     335:	bf 61 00 00 00       	mov    $0x61,%edi
     33a:	e9 5e ff ff ff       	jmp    29d <gettoken+0x5d>
     33f:	90                   	nop
  while(s < es && strchr(whitespace, *s))
    s++;
  if(q)
    *q = s;
  ret = *s;
  switch(*s){
     340:	80 fa 29             	cmp    $0x29,%dl
     343:	7f a9                	jg     2ee <gettoken+0xae>
     345:	80 fa 28             	cmp    $0x28,%dl
     348:	0f 8d 4c ff ff ff    	jge    29a <gettoken+0x5a>
     34e:	84 d2                	test   %dl,%dl
     350:	0f 84 47 ff ff ff    	je     29d <gettoken+0x5d>
     356:	80 fa 26             	cmp    $0x26,%dl
     359:	75 93                	jne    2ee <gettoken+0xae>
     35b:	90                   	nop
     35c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     360:	e9 35 ff ff ff       	jmp    29a <gettoken+0x5a>
     365:	8d 76 00             	lea    0x0(%esi),%esi
  case '&':
  case '<':
    s++;
    break;
  case '>':
    s++;
     368:	83 c3 01             	add    $0x1,%ebx
    if(*s == '>'){
     36b:	80 3b 3e             	cmpb   $0x3e,(%ebx)
     36e:	66 90                	xchg   %ax,%ax
     370:	0f 85 27 ff ff ff    	jne    29d <gettoken+0x5d>
      ret = '+';
      s++;
     376:	83 c3 01             	add    $0x1,%ebx
     379:	bf 2b 00 00 00       	mov    $0x2b,%edi
     37e:	66 90                	xchg   %ax,%ax
     380:	e9 18 ff ff ff       	jmp    29d <gettoken+0x5d>
     385:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     389:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000390 <backcmd>:
  return (struct cmd*)cmd;
}

struct cmd*
backcmd(struct cmd *subcmd)
{
     390:	55                   	push   %ebp
     391:	89 e5                	mov    %esp,%ebp
     393:	53                   	push   %ebx
     394:	83 ec 14             	sub    $0x14,%esp
  struct backcmd *cmd;

  cmd = malloc(sizeof(*cmd));
     397:	c7 04 24 08 00 00 00 	movl   $0x8,(%esp)
     39e:	e8 5d 11 00 00       	call   1500 <malloc>
  memset(cmd, 0, sizeof(*cmd));
     3a3:	c7 44 24 08 08 00 00 	movl   $0x8,0x8(%esp)
     3aa:	00 
     3ab:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     3b2:	00 
struct cmd*
backcmd(struct cmd *subcmd)
{
  struct backcmd *cmd;

  cmd = malloc(sizeof(*cmd));
     3b3:	89 c3                	mov    %eax,%ebx
  memset(cmd, 0, sizeof(*cmd));
     3b5:	89 04 24             	mov    %eax,(%esp)
     3b8:	e8 c3 0b 00 00       	call   f80 <memset>
  cmd->type = BACK;
     3bd:	c7 03 05 00 00 00    	movl   $0x5,(%ebx)
  cmd->cmd = subcmd;
     3c3:	8b 45 08             	mov    0x8(%ebp),%eax
     3c6:	89 43 04             	mov    %eax,0x4(%ebx)
  return (struct cmd*)cmd;
}
     3c9:	89 d8                	mov    %ebx,%eax
     3cb:	83 c4 14             	add    $0x14,%esp
     3ce:	5b                   	pop    %ebx
     3cf:	5d                   	pop    %ebp
     3d0:	c3                   	ret    
     3d1:	eb 0d                	jmp    3e0 <listcmd>
     3d3:	90                   	nop
     3d4:	90                   	nop
     3d5:	90                   	nop
     3d6:	90                   	nop
     3d7:	90                   	nop
     3d8:	90                   	nop
     3d9:	90                   	nop
     3da:	90                   	nop
     3db:	90                   	nop
     3dc:	90                   	nop
     3dd:	90                   	nop
     3de:	90                   	nop
     3df:	90                   	nop

000003e0 <listcmd>:
  return (struct cmd*)cmd;
}

struct cmd*
listcmd(struct cmd *left, struct cmd *right)
{
     3e0:	55                   	push   %ebp
     3e1:	89 e5                	mov    %esp,%ebp
     3e3:	53                   	push   %ebx
     3e4:	83 ec 14             	sub    $0x14,%esp
  struct listcmd *cmd;

  cmd = malloc(sizeof(*cmd));
     3e7:	c7 04 24 0c 00 00 00 	movl   $0xc,(%esp)
     3ee:	e8 0d 11 00 00       	call   1500 <malloc>
  memset(cmd, 0, sizeof(*cmd));
     3f3:	c7 44 24 08 0c 00 00 	movl   $0xc,0x8(%esp)
     3fa:	00 
     3fb:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     402:	00 
struct cmd*
listcmd(struct cmd *left, struct cmd *right)
{
  struct listcmd *cmd;

  cmd = malloc(sizeof(*cmd));
     403:	89 c3                	mov    %eax,%ebx
  memset(cmd, 0, sizeof(*cmd));
     405:	89 04 24             	mov    %eax,(%esp)
     408:	e8 73 0b 00 00       	call   f80 <memset>
  cmd->type = LIST;
     40d:	c7 03 04 00 00 00    	movl   $0x4,(%ebx)
  cmd->left = left;
     413:	8b 45 08             	mov    0x8(%ebp),%eax
     416:	89 43 04             	mov    %eax,0x4(%ebx)
  cmd->right = right;
     419:	8b 45 0c             	mov    0xc(%ebp),%eax
     41c:	89 43 08             	mov    %eax,0x8(%ebx)
  return (struct cmd*)cmd;
}
     41f:	89 d8                	mov    %ebx,%eax
     421:	83 c4 14             	add    $0x14,%esp
     424:	5b                   	pop    %ebx
     425:	5d                   	pop    %ebp
     426:	c3                   	ret    
     427:	89 f6                	mov    %esi,%esi
     429:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000430 <pipecmd>:
  return (struct cmd*)cmd;
}

struct cmd*
pipecmd(struct cmd *left, struct cmd *right)
{
     430:	55                   	push   %ebp
     431:	89 e5                	mov    %esp,%ebp
     433:	53                   	push   %ebx
     434:	83 ec 14             	sub    $0x14,%esp
  struct pipecmd *cmd;

  cmd = malloc(sizeof(*cmd));
     437:	c7 04 24 0c 00 00 00 	movl   $0xc,(%esp)
     43e:	e8 bd 10 00 00       	call   1500 <malloc>
  memset(cmd, 0, sizeof(*cmd));
     443:	c7 44 24 08 0c 00 00 	movl   $0xc,0x8(%esp)
     44a:	00 
     44b:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     452:	00 
struct cmd*
pipecmd(struct cmd *left, struct cmd *right)
{
  struct pipecmd *cmd;

  cmd = malloc(sizeof(*cmd));
     453:	89 c3                	mov    %eax,%ebx
  memset(cmd, 0, sizeof(*cmd));
     455:	89 04 24             	mov    %eax,(%esp)
     458:	e8 23 0b 00 00       	call   f80 <memset>
  cmd->type = PIPE;
     45d:	c7 03 03 00 00 00    	movl   $0x3,(%ebx)
  cmd->left = left;
     463:	8b 45 08             	mov    0x8(%ebp),%eax
     466:	89 43 04             	mov    %eax,0x4(%ebx)
  cmd->right = right;
     469:	8b 45 0c             	mov    0xc(%ebp),%eax
     46c:	89 43 08             	mov    %eax,0x8(%ebx)
  return (struct cmd*)cmd;
}
     46f:	89 d8                	mov    %ebx,%eax
     471:	83 c4 14             	add    $0x14,%esp
     474:	5b                   	pop    %ebx
     475:	5d                   	pop    %ebp
     476:	c3                   	ret    
     477:	89 f6                	mov    %esi,%esi
     479:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000480 <redircmd>:
  return (struct cmd*)cmd;
}

struct cmd*
redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
     480:	55                   	push   %ebp
     481:	89 e5                	mov    %esp,%ebp
     483:	53                   	push   %ebx
     484:	83 ec 14             	sub    $0x14,%esp
  struct redircmd *cmd;

  cmd = malloc(sizeof(*cmd));
     487:	c7 04 24 18 00 00 00 	movl   $0x18,(%esp)
     48e:	e8 6d 10 00 00       	call   1500 <malloc>
  memset(cmd, 0, sizeof(*cmd));
     493:	c7 44 24 08 18 00 00 	movl   $0x18,0x8(%esp)
     49a:	00 
     49b:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     4a2:	00 
struct cmd*
redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
  struct redircmd *cmd;

  cmd = malloc(sizeof(*cmd));
     4a3:	89 c3                	mov    %eax,%ebx
  memset(cmd, 0, sizeof(*cmd));
     4a5:	89 04 24             	mov    %eax,(%esp)
     4a8:	e8 d3 0a 00 00       	call   f80 <memset>
  cmd->type = REDIR;
     4ad:	c7 03 02 00 00 00    	movl   $0x2,(%ebx)
  cmd->cmd = subcmd;
     4b3:	8b 45 08             	mov    0x8(%ebp),%eax
     4b6:	89 43 04             	mov    %eax,0x4(%ebx)
  cmd->file = file;
     4b9:	8b 45 0c             	mov    0xc(%ebp),%eax
     4bc:	89 43 08             	mov    %eax,0x8(%ebx)
  cmd->efile = efile;
     4bf:	8b 45 10             	mov    0x10(%ebp),%eax
     4c2:	89 43 0c             	mov    %eax,0xc(%ebx)
  cmd->mode = mode;
     4c5:	8b 45 14             	mov    0x14(%ebp),%eax
     4c8:	89 43 10             	mov    %eax,0x10(%ebx)
  cmd->fd = fd;
     4cb:	8b 45 18             	mov    0x18(%ebp),%eax
     4ce:	89 43 14             	mov    %eax,0x14(%ebx)
  return (struct cmd*)cmd;
}
     4d1:	89 d8                	mov    %ebx,%eax
     4d3:	83 c4 14             	add    $0x14,%esp
     4d6:	5b                   	pop    %ebx
     4d7:	5d                   	pop    %ebp
     4d8:	c3                   	ret    
     4d9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

000004e0 <execcmd>:

// Constructors

struct cmd*
execcmd(void)
{
     4e0:	55                   	push   %ebp
     4e1:	89 e5                	mov    %esp,%ebp
     4e3:	53                   	push   %ebx
     4e4:	83 ec 14             	sub    $0x14,%esp
  struct execcmd *cmd;

  cmd = malloc(sizeof(*cmd));
     4e7:	c7 04 24 54 00 00 00 	movl   $0x54,(%esp)
     4ee:	e8 0d 10 00 00       	call   1500 <malloc>
  memset(cmd, 0, sizeof(*cmd));
     4f3:	c7 44 24 08 54 00 00 	movl   $0x54,0x8(%esp)
     4fa:	00 
     4fb:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     502:	00 
struct cmd*
execcmd(void)
{
  struct execcmd *cmd;

  cmd = malloc(sizeof(*cmd));
     503:	89 c3                	mov    %eax,%ebx
  memset(cmd, 0, sizeof(*cmd));
     505:	89 04 24             	mov    %eax,(%esp)
     508:	e8 73 0a 00 00       	call   f80 <memset>
  cmd->type = EXEC;
  return (struct cmd*)cmd;
}
     50d:	89 d8                	mov    %ebx,%eax
{
  struct execcmd *cmd;

  cmd = malloc(sizeof(*cmd));
  memset(cmd, 0, sizeof(*cmd));
  cmd->type = EXEC;
     50f:	c7 03 01 00 00 00    	movl   $0x1,(%ebx)
  return (struct cmd*)cmd;
}
     515:	83 c4 14             	add    $0x14,%esp
     518:	5b                   	pop    %ebx
     519:	5d                   	pop    %ebp
     51a:	c3                   	ret    
     51b:	90                   	nop
     51c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00000520 <panic>:
  exit();
}

void
panic(char *s)
{
     520:	55                   	push   %ebp
     521:	89 e5                	mov    %esp,%ebp
     523:	83 ec 18             	sub    $0x18,%esp
  printf(2, "%s\n", s);
     526:	8b 45 08             	mov    0x8(%ebp),%eax
     529:	c7 44 24 04 79 16 00 	movl   $0x1679,0x4(%esp)
     530:	00 
     531:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     538:	89 44 24 08          	mov    %eax,0x8(%esp)
     53c:	e8 1f 0d 00 00       	call   1260 <printf>
  exit();
     541:	e8 c2 0b 00 00       	call   1108 <exit>
     546:	8d 76 00             	lea    0x0(%esi),%esi
     549:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000550 <parseredirs>:
  return cmd;
}

struct cmd*
parseredirs(struct cmd *cmd, char **ps, char *es)
{
     550:	55                   	push   %ebp
     551:	89 e5                	mov    %esp,%ebp
     553:	57                   	push   %edi
     554:	56                   	push   %esi
     555:	53                   	push   %ebx
     556:	83 ec 3c             	sub    $0x3c,%esp
     559:	8b 7d 0c             	mov    0xc(%ebp),%edi
     55c:	8b 75 10             	mov    0x10(%ebp),%esi
     55f:	90                   	nop
  int tok;
  char *q, *eq;

  while(peek(ps, es, "<>")){
     560:	c7 44 24 08 2d 16 00 	movl   $0x162d,0x8(%esp)
     567:	00 
     568:	89 74 24 04          	mov    %esi,0x4(%esp)
     56c:	89 3c 24             	mov    %edi,(%esp)
     56f:	e8 4c fc ff ff       	call   1c0 <peek>
     574:	85 c0                	test   %eax,%eax
     576:	0f 84 a4 00 00 00    	je     620 <parseredirs+0xd0>
    tok = gettoken(ps, es, 0, 0);
     57c:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     583:	00 
     584:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
     58b:	00 
     58c:	89 74 24 04          	mov    %esi,0x4(%esp)
     590:	89 3c 24             	mov    %edi,(%esp)
     593:	e8 a8 fc ff ff       	call   240 <gettoken>
    if(gettoken(ps, es, &q, &eq) != 'a')
     598:	89 74 24 04          	mov    %esi,0x4(%esp)
     59c:	89 3c 24             	mov    %edi,(%esp)
{
  int tok;
  char *q, *eq;

  while(peek(ps, es, "<>")){
    tok = gettoken(ps, es, 0, 0);
     59f:	89 c3                	mov    %eax,%ebx
    if(gettoken(ps, es, &q, &eq) != 'a')
     5a1:	8d 45 e0             	lea    -0x20(%ebp),%eax
     5a4:	89 44 24 0c          	mov    %eax,0xc(%esp)
     5a8:	8d 45 e4             	lea    -0x1c(%ebp),%eax
     5ab:	89 44 24 08          	mov    %eax,0x8(%esp)
     5af:	e8 8c fc ff ff       	call   240 <gettoken>
     5b4:	83 f8 61             	cmp    $0x61,%eax
     5b7:	74 0c                	je     5c5 <parseredirs+0x75>
      panic("missing file for redirection");
     5b9:	c7 04 24 10 16 00 00 	movl   $0x1610,(%esp)
     5c0:	e8 5b ff ff ff       	call   520 <panic>
    switch(tok){
     5c5:	83 fb 3c             	cmp    $0x3c,%ebx
     5c8:	74 3e                	je     608 <parseredirs+0xb8>
     5ca:	83 fb 3e             	cmp    $0x3e,%ebx
     5cd:	74 05                	je     5d4 <parseredirs+0x84>
     5cf:	83 fb 2b             	cmp    $0x2b,%ebx
     5d2:	75 8c                	jne    560 <parseredirs+0x10>
      break;
    case '>':
      cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
      break;
    case '+':  // >>
      cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
     5d4:	c7 44 24 10 01 00 00 	movl   $0x1,0x10(%esp)
     5db:	00 
     5dc:	c7 44 24 0c 01 02 00 	movl   $0x201,0xc(%esp)
     5e3:	00 
     5e4:	8b 45 e0             	mov    -0x20(%ebp),%eax
     5e7:	89 44 24 08          	mov    %eax,0x8(%esp)
     5eb:	8b 45 e4             	mov    -0x1c(%ebp),%eax
     5ee:	89 44 24 04          	mov    %eax,0x4(%esp)
     5f2:	8b 45 08             	mov    0x8(%ebp),%eax
     5f5:	89 04 24             	mov    %eax,(%esp)
     5f8:	e8 83 fe ff ff       	call   480 <redircmd>
     5fd:	89 45 08             	mov    %eax,0x8(%ebp)
     600:	e9 5b ff ff ff       	jmp    560 <parseredirs+0x10>
     605:	8d 76 00             	lea    0x0(%esi),%esi
    tok = gettoken(ps, es, 0, 0);
    if(gettoken(ps, es, &q, &eq) != 'a')
      panic("missing file for redirection");
    switch(tok){
    case '<':
      cmd = redircmd(cmd, q, eq, O_RDONLY, 0);
     608:	c7 44 24 10 00 00 00 	movl   $0x0,0x10(%esp)
     60f:	00 
     610:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     617:	00 
     618:	eb ca                	jmp    5e4 <parseredirs+0x94>
     61a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
      cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
      break;
    }
  }
  return cmd;
}
     620:	8b 45 08             	mov    0x8(%ebp),%eax
     623:	83 c4 3c             	add    $0x3c,%esp
     626:	5b                   	pop    %ebx
     627:	5e                   	pop    %esi
     628:	5f                   	pop    %edi
     629:	5d                   	pop    %ebp
     62a:	c3                   	ret    
     62b:	90                   	nop
     62c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00000630 <parseexec>:
  return cmd;
}

struct cmd*
parseexec(char **ps, char *es)
{
     630:	55                   	push   %ebp
     631:	89 e5                	mov    %esp,%ebp
     633:	57                   	push   %edi
     634:	56                   	push   %esi
     635:	53                   	push   %ebx
     636:	83 ec 3c             	sub    $0x3c,%esp
     639:	8b 75 08             	mov    0x8(%ebp),%esi
     63c:	8b 7d 0c             	mov    0xc(%ebp),%edi
  char *q, *eq;
  int tok, argc;
  struct execcmd *cmd;
  struct cmd *ret;
  
  if(peek(ps, es, "("))
     63f:	c7 44 24 08 30 16 00 	movl   $0x1630,0x8(%esp)
     646:	00 
     647:	89 34 24             	mov    %esi,(%esp)
     64a:	89 7c 24 04          	mov    %edi,0x4(%esp)
     64e:	e8 6d fb ff ff       	call   1c0 <peek>
     653:	85 c0                	test   %eax,%eax
     655:	0f 85 cd 00 00 00    	jne    728 <parseexec+0xf8>
    return parseblock(ps, es);

  ret = execcmd();
     65b:	e8 80 fe ff ff       	call   4e0 <execcmd>
  cmd = (struct execcmd*)ret;

  argc = 0;
  ret = parseredirs(ret, ps, es);
     660:	31 db                	xor    %ebx,%ebx
  struct cmd *ret;
  
  if(peek(ps, es, "("))
    return parseblock(ps, es);

  ret = execcmd();
     662:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  cmd = (struct execcmd*)ret;

  argc = 0;
  ret = parseredirs(ret, ps, es);
     665:	89 7c 24 08          	mov    %edi,0x8(%esp)
     669:	89 74 24 04          	mov    %esi,0x4(%esp)
     66d:	89 04 24             	mov    %eax,(%esp)
     670:	e8 db fe ff ff       	call   550 <parseredirs>
     675:	89 45 d0             	mov    %eax,-0x30(%ebp)
  while(!peek(ps, es, "|)&;")){
     678:	eb 1c                	jmp    696 <parseexec+0x66>
     67a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    cmd->argv[argc] = q;
    cmd->eargv[argc] = eq;
    argc++;
    if(argc >= MAXARGS)
      panic("too many args");
    ret = parseredirs(ret, ps, es);
     680:	89 7c 24 08          	mov    %edi,0x8(%esp)
     684:	89 74 24 04          	mov    %esi,0x4(%esp)
     688:	8b 45 d0             	mov    -0x30(%ebp),%eax
     68b:	89 04 24             	mov    %eax,(%esp)
     68e:	e8 bd fe ff ff       	call   550 <parseredirs>
     693:	89 45 d0             	mov    %eax,-0x30(%ebp)
  ret = execcmd();
  cmd = (struct execcmd*)ret;

  argc = 0;
  ret = parseredirs(ret, ps, es);
  while(!peek(ps, es, "|)&;")){
     696:	c7 44 24 08 47 16 00 	movl   $0x1647,0x8(%esp)
     69d:	00 
     69e:	89 7c 24 04          	mov    %edi,0x4(%esp)
     6a2:	89 34 24             	mov    %esi,(%esp)
     6a5:	e8 16 fb ff ff       	call   1c0 <peek>
     6aa:	85 c0                	test   %eax,%eax
     6ac:	75 5a                	jne    708 <parseexec+0xd8>
    if((tok=gettoken(ps, es, &q, &eq)) == 0)
     6ae:	8d 45 e0             	lea    -0x20(%ebp),%eax
     6b1:	8d 55 e4             	lea    -0x1c(%ebp),%edx
     6b4:	89 44 24 0c          	mov    %eax,0xc(%esp)
     6b8:	89 54 24 08          	mov    %edx,0x8(%esp)
     6bc:	89 7c 24 04          	mov    %edi,0x4(%esp)
     6c0:	89 34 24             	mov    %esi,(%esp)
     6c3:	e8 78 fb ff ff       	call   240 <gettoken>
     6c8:	85 c0                	test   %eax,%eax
     6ca:	74 3c                	je     708 <parseexec+0xd8>
      break;
    if(tok != 'a')
     6cc:	83 f8 61             	cmp    $0x61,%eax
     6cf:	74 0c                	je     6dd <parseexec+0xad>
      panic("syntax");
     6d1:	c7 04 24 32 16 00 00 	movl   $0x1632,(%esp)
     6d8:	e8 43 fe ff ff       	call   520 <panic>
    cmd->argv[argc] = q;
     6dd:	8b 45 e4             	mov    -0x1c(%ebp),%eax
     6e0:	8b 55 d4             	mov    -0x2c(%ebp),%edx
     6e3:	89 44 9a 04          	mov    %eax,0x4(%edx,%ebx,4)
    cmd->eargv[argc] = eq;
     6e7:	8b 45 e0             	mov    -0x20(%ebp),%eax
     6ea:	89 44 9a 2c          	mov    %eax,0x2c(%edx,%ebx,4)
    argc++;
     6ee:	83 c3 01             	add    $0x1,%ebx
    if(argc >= MAXARGS)
     6f1:	83 fb 09             	cmp    $0x9,%ebx
     6f4:	7e 8a                	jle    680 <parseexec+0x50>
      panic("too many args");
     6f6:	c7 04 24 39 16 00 00 	movl   $0x1639,(%esp)
     6fd:	e8 1e fe ff ff       	call   520 <panic>
     702:	e9 79 ff ff ff       	jmp    680 <parseexec+0x50>
     707:	90                   	nop
    ret = parseredirs(ret, ps, es);
  }
  cmd->argv[argc] = 0;
     708:	8b 55 d4             	mov    -0x2c(%ebp),%edx
     70b:	c7 44 9a 04 00 00 00 	movl   $0x0,0x4(%edx,%ebx,4)
     712:	00 
  cmd->eargv[argc] = 0;
     713:	c7 44 9a 2c 00 00 00 	movl   $0x0,0x2c(%edx,%ebx,4)
     71a:	00 
  return ret;
}
     71b:	8b 45 d0             	mov    -0x30(%ebp),%eax
     71e:	83 c4 3c             	add    $0x3c,%esp
     721:	5b                   	pop    %ebx
     722:	5e                   	pop    %esi
     723:	5f                   	pop    %edi
     724:	5d                   	pop    %ebp
     725:	c3                   	ret    
     726:	66 90                	xchg   %ax,%ax
  int tok, argc;
  struct execcmd *cmd;
  struct cmd *ret;
  
  if(peek(ps, es, "("))
    return parseblock(ps, es);
     728:	89 7c 24 04          	mov    %edi,0x4(%esp)
     72c:	89 34 24             	mov    %esi,(%esp)
     72f:	e8 6c 01 00 00       	call   8a0 <parseblock>
     734:	89 45 d0             	mov    %eax,-0x30(%ebp)
    ret = parseredirs(ret, ps, es);
  }
  cmd->argv[argc] = 0;
  cmd->eargv[argc] = 0;
  return ret;
}
     737:	8b 45 d0             	mov    -0x30(%ebp),%eax
     73a:	83 c4 3c             	add    $0x3c,%esp
     73d:	5b                   	pop    %ebx
     73e:	5e                   	pop    %esi
     73f:	5f                   	pop    %edi
     740:	5d                   	pop    %ebp
     741:	c3                   	ret    
     742:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
     749:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000750 <parsepipe>:
  return cmd;
}

struct cmd*
parsepipe(char **ps, char *es)
{
     750:	55                   	push   %ebp
     751:	89 e5                	mov    %esp,%ebp
     753:	83 ec 28             	sub    $0x28,%esp
     756:	89 5d f4             	mov    %ebx,-0xc(%ebp)
     759:	8b 5d 08             	mov    0x8(%ebp),%ebx
     75c:	89 75 f8             	mov    %esi,-0x8(%ebp)
     75f:	8b 75 0c             	mov    0xc(%ebp),%esi
     762:	89 7d fc             	mov    %edi,-0x4(%ebp)
  struct cmd *cmd;

  cmd = parseexec(ps, es);
     765:	89 1c 24             	mov    %ebx,(%esp)
     768:	89 74 24 04          	mov    %esi,0x4(%esp)
     76c:	e8 bf fe ff ff       	call   630 <parseexec>
  if(peek(ps, es, "|")){
     771:	c7 44 24 08 4c 16 00 	movl   $0x164c,0x8(%esp)
     778:	00 
     779:	89 74 24 04          	mov    %esi,0x4(%esp)
     77d:	89 1c 24             	mov    %ebx,(%esp)
struct cmd*
parsepipe(char **ps, char *es)
{
  struct cmd *cmd;

  cmd = parseexec(ps, es);
     780:	89 c7                	mov    %eax,%edi
  if(peek(ps, es, "|")){
     782:	e8 39 fa ff ff       	call   1c0 <peek>
     787:	85 c0                	test   %eax,%eax
     789:	75 15                	jne    7a0 <parsepipe+0x50>
    gettoken(ps, es, 0, 0);
    cmd = pipecmd(cmd, parsepipe(ps, es));
  }
  return cmd;
}
     78b:	89 f8                	mov    %edi,%eax
     78d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
     790:	8b 75 f8             	mov    -0x8(%ebp),%esi
     793:	8b 7d fc             	mov    -0x4(%ebp),%edi
     796:	89 ec                	mov    %ebp,%esp
     798:	5d                   	pop    %ebp
     799:	c3                   	ret    
     79a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
{
  struct cmd *cmd;

  cmd = parseexec(ps, es);
  if(peek(ps, es, "|")){
    gettoken(ps, es, 0, 0);
     7a0:	89 74 24 04          	mov    %esi,0x4(%esp)
     7a4:	89 1c 24             	mov    %ebx,(%esp)
     7a7:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     7ae:	00 
     7af:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
     7b6:	00 
     7b7:	e8 84 fa ff ff       	call   240 <gettoken>
    cmd = pipecmd(cmd, parsepipe(ps, es));
     7bc:	89 74 24 04          	mov    %esi,0x4(%esp)
     7c0:	89 1c 24             	mov    %ebx,(%esp)
     7c3:	e8 88 ff ff ff       	call   750 <parsepipe>
  }
  return cmd;
}
     7c8:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  struct cmd *cmd;

  cmd = parseexec(ps, es);
  if(peek(ps, es, "|")){
    gettoken(ps, es, 0, 0);
    cmd = pipecmd(cmd, parsepipe(ps, es));
     7cb:	89 7d 08             	mov    %edi,0x8(%ebp)
  }
  return cmd;
}
     7ce:	8b 75 f8             	mov    -0x8(%ebp),%esi
     7d1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  struct cmd *cmd;

  cmd = parseexec(ps, es);
  if(peek(ps, es, "|")){
    gettoken(ps, es, 0, 0);
    cmd = pipecmd(cmd, parsepipe(ps, es));
     7d4:	89 45 0c             	mov    %eax,0xc(%ebp)
  }
  return cmd;
}
     7d7:	89 ec                	mov    %ebp,%esp
     7d9:	5d                   	pop    %ebp
  struct cmd *cmd;

  cmd = parseexec(ps, es);
  if(peek(ps, es, "|")){
    gettoken(ps, es, 0, 0);
    cmd = pipecmd(cmd, parsepipe(ps, es));
     7da:	e9 51 fc ff ff       	jmp    430 <pipecmd>
     7df:	90                   	nop

000007e0 <parseline>:
  return cmd;
}

struct cmd*
parseline(char **ps, char *es)
{
     7e0:	55                   	push   %ebp
     7e1:	89 e5                	mov    %esp,%ebp
     7e3:	57                   	push   %edi
     7e4:	56                   	push   %esi
     7e5:	53                   	push   %ebx
     7e6:	83 ec 1c             	sub    $0x1c,%esp
     7e9:	8b 5d 08             	mov    0x8(%ebp),%ebx
     7ec:	8b 75 0c             	mov    0xc(%ebp),%esi
  struct cmd *cmd;

  cmd = parsepipe(ps, es);
     7ef:	89 1c 24             	mov    %ebx,(%esp)
     7f2:	89 74 24 04          	mov    %esi,0x4(%esp)
     7f6:	e8 55 ff ff ff       	call   750 <parsepipe>
     7fb:	89 c7                	mov    %eax,%edi
  while(peek(ps, es, "&")){
     7fd:	eb 27                	jmp    826 <parseline+0x46>
     7ff:	90                   	nop
    gettoken(ps, es, 0, 0);
     800:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     807:	00 
     808:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
     80f:	00 
     810:	89 74 24 04          	mov    %esi,0x4(%esp)
     814:	89 1c 24             	mov    %ebx,(%esp)
     817:	e8 24 fa ff ff       	call   240 <gettoken>
    cmd = backcmd(cmd);
     81c:	89 3c 24             	mov    %edi,(%esp)
     81f:	e8 6c fb ff ff       	call   390 <backcmd>
     824:	89 c7                	mov    %eax,%edi
parseline(char **ps, char *es)
{
  struct cmd *cmd;

  cmd = parsepipe(ps, es);
  while(peek(ps, es, "&")){
     826:	c7 44 24 08 4e 16 00 	movl   $0x164e,0x8(%esp)
     82d:	00 
     82e:	89 74 24 04          	mov    %esi,0x4(%esp)
     832:	89 1c 24             	mov    %ebx,(%esp)
     835:	e8 86 f9 ff ff       	call   1c0 <peek>
     83a:	85 c0                	test   %eax,%eax
     83c:	75 c2                	jne    800 <parseline+0x20>
    gettoken(ps, es, 0, 0);
    cmd = backcmd(cmd);
  }
  if(peek(ps, es, ";")){
     83e:	c7 44 24 08 4a 16 00 	movl   $0x164a,0x8(%esp)
     845:	00 
     846:	89 74 24 04          	mov    %esi,0x4(%esp)
     84a:	89 1c 24             	mov    %ebx,(%esp)
     84d:	e8 6e f9 ff ff       	call   1c0 <peek>
     852:	85 c0                	test   %eax,%eax
     854:	75 0a                	jne    860 <parseline+0x80>
    gettoken(ps, es, 0, 0);
    cmd = listcmd(cmd, parseline(ps, es));
  }
  return cmd;
}
     856:	83 c4 1c             	add    $0x1c,%esp
     859:	89 f8                	mov    %edi,%eax
     85b:	5b                   	pop    %ebx
     85c:	5e                   	pop    %esi
     85d:	5f                   	pop    %edi
     85e:	5d                   	pop    %ebp
     85f:	c3                   	ret    
  while(peek(ps, es, "&")){
    gettoken(ps, es, 0, 0);
    cmd = backcmd(cmd);
  }
  if(peek(ps, es, ";")){
    gettoken(ps, es, 0, 0);
     860:	89 74 24 04          	mov    %esi,0x4(%esp)
     864:	89 1c 24             	mov    %ebx,(%esp)
     867:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     86e:	00 
     86f:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
     876:	00 
     877:	e8 c4 f9 ff ff       	call   240 <gettoken>
    cmd = listcmd(cmd, parseline(ps, es));
     87c:	89 74 24 04          	mov    %esi,0x4(%esp)
     880:	89 1c 24             	mov    %ebx,(%esp)
     883:	e8 58 ff ff ff       	call   7e0 <parseline>
     888:	89 7d 08             	mov    %edi,0x8(%ebp)
     88b:	89 45 0c             	mov    %eax,0xc(%ebp)
  }
  return cmd;
}
     88e:	83 c4 1c             	add    $0x1c,%esp
     891:	5b                   	pop    %ebx
     892:	5e                   	pop    %esi
     893:	5f                   	pop    %edi
     894:	5d                   	pop    %ebp
    gettoken(ps, es, 0, 0);
    cmd = backcmd(cmd);
  }
  if(peek(ps, es, ";")){
    gettoken(ps, es, 0, 0);
    cmd = listcmd(cmd, parseline(ps, es));
     895:	e9 46 fb ff ff       	jmp    3e0 <listcmd>
     89a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

000008a0 <parseblock>:
  return cmd;
}

struct cmd*
parseblock(char **ps, char *es)
{
     8a0:	55                   	push   %ebp
     8a1:	89 e5                	mov    %esp,%ebp
     8a3:	83 ec 28             	sub    $0x28,%esp
     8a6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
     8a9:	8b 5d 08             	mov    0x8(%ebp),%ebx
     8ac:	89 75 f8             	mov    %esi,-0x8(%ebp)
     8af:	8b 75 0c             	mov    0xc(%ebp),%esi
     8b2:	89 7d fc             	mov    %edi,-0x4(%ebp)
  struct cmd *cmd;

  if(!peek(ps, es, "("))
     8b5:	c7 44 24 08 30 16 00 	movl   $0x1630,0x8(%esp)
     8bc:	00 
     8bd:	89 1c 24             	mov    %ebx,(%esp)
     8c0:	89 74 24 04          	mov    %esi,0x4(%esp)
     8c4:	e8 f7 f8 ff ff       	call   1c0 <peek>
     8c9:	85 c0                	test   %eax,%eax
     8cb:	0f 84 87 00 00 00    	je     958 <parseblock+0xb8>
    panic("parseblock");
  gettoken(ps, es, 0, 0);
     8d1:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     8d8:	00 
     8d9:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
     8e0:	00 
     8e1:	89 74 24 04          	mov    %esi,0x4(%esp)
     8e5:	89 1c 24             	mov    %ebx,(%esp)
     8e8:	e8 53 f9 ff ff       	call   240 <gettoken>
  cmd = parseline(ps, es);
     8ed:	89 74 24 04          	mov    %esi,0x4(%esp)
     8f1:	89 1c 24             	mov    %ebx,(%esp)
     8f4:	e8 e7 fe ff ff       	call   7e0 <parseline>
  if(!peek(ps, es, ")"))
     8f9:	c7 44 24 08 6c 16 00 	movl   $0x166c,0x8(%esp)
     900:	00 
     901:	89 74 24 04          	mov    %esi,0x4(%esp)
     905:	89 1c 24             	mov    %ebx,(%esp)
  struct cmd *cmd;

  if(!peek(ps, es, "("))
    panic("parseblock");
  gettoken(ps, es, 0, 0);
  cmd = parseline(ps, es);
     908:	89 c7                	mov    %eax,%edi
  if(!peek(ps, es, ")"))
     90a:	e8 b1 f8 ff ff       	call   1c0 <peek>
     90f:	85 c0                	test   %eax,%eax
     911:	75 0c                	jne    91f <parseblock+0x7f>
    panic("syntax - missing )");
     913:	c7 04 24 5b 16 00 00 	movl   $0x165b,(%esp)
     91a:	e8 01 fc ff ff       	call   520 <panic>
  gettoken(ps, es, 0, 0);
     91f:	89 74 24 04          	mov    %esi,0x4(%esp)
     923:	89 1c 24             	mov    %ebx,(%esp)
     926:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
     92d:	00 
     92e:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
     935:	00 
     936:	e8 05 f9 ff ff       	call   240 <gettoken>
  cmd = parseredirs(cmd, ps, es);
     93b:	89 74 24 08          	mov    %esi,0x8(%esp)
     93f:	89 5c 24 04          	mov    %ebx,0x4(%esp)
     943:	89 3c 24             	mov    %edi,(%esp)
     946:	e8 05 fc ff ff       	call   550 <parseredirs>
  return cmd;
}
     94b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
     94e:	8b 75 f8             	mov    -0x8(%ebp),%esi
     951:	8b 7d fc             	mov    -0x4(%ebp),%edi
     954:	89 ec                	mov    %ebp,%esp
     956:	5d                   	pop    %ebp
     957:	c3                   	ret    
parseblock(char **ps, char *es)
{
  struct cmd *cmd;

  if(!peek(ps, es, "("))
    panic("parseblock");
     958:	c7 04 24 50 16 00 00 	movl   $0x1650,(%esp)
     95f:	e8 bc fb ff ff       	call   520 <panic>
     964:	e9 68 ff ff ff       	jmp    8d1 <parseblock+0x31>
     969:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00000970 <parsecmd>:
struct cmd *parseexec(char**, char*);
struct cmd *nulterminate(struct cmd*);

struct cmd*
parsecmd(char *s)
{
     970:	55                   	push   %ebp
     971:	89 e5                	mov    %esp,%ebp
     973:	56                   	push   %esi
     974:	53                   	push   %ebx
     975:	83 ec 10             	sub    $0x10,%esp
  char *es;
  struct cmd *cmd;

  es = s + strlen(s);
     978:	8b 5d 08             	mov    0x8(%ebp),%ebx
     97b:	89 1c 24             	mov    %ebx,(%esp)
     97e:	e8 dd 05 00 00       	call   f60 <strlen>
     983:	01 c3                	add    %eax,%ebx
  cmd = parseline(&s, es);
     985:	8d 45 08             	lea    0x8(%ebp),%eax
     988:	89 5c 24 04          	mov    %ebx,0x4(%esp)
     98c:	89 04 24             	mov    %eax,(%esp)
     98f:	e8 4c fe ff ff       	call   7e0 <parseline>
  peek(&s, es, "");
     994:	c7 44 24 08 a0 16 00 	movl   $0x16a0,0x8(%esp)
     99b:	00 
     99c:	89 5c 24 04          	mov    %ebx,0x4(%esp)
{
  char *es;
  struct cmd *cmd;

  es = s + strlen(s);
  cmd = parseline(&s, es);
     9a0:	89 c6                	mov    %eax,%esi
  peek(&s, es, "");
     9a2:	8d 45 08             	lea    0x8(%ebp),%eax
     9a5:	89 04 24             	mov    %eax,(%esp)
     9a8:	e8 13 f8 ff ff       	call   1c0 <peek>
  if(s != es){
     9ad:	8b 45 08             	mov    0x8(%ebp),%eax
     9b0:	39 d8                	cmp    %ebx,%eax
     9b2:	74 24                	je     9d8 <parsecmd+0x68>
    printf(2, "leftovers: %s\n", s);
     9b4:	89 44 24 08          	mov    %eax,0x8(%esp)
     9b8:	c7 44 24 04 6e 16 00 	movl   $0x166e,0x4(%esp)
     9bf:	00 
     9c0:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     9c7:	e8 94 08 00 00       	call   1260 <printf>
    panic("syntax");
     9cc:	c7 04 24 32 16 00 00 	movl   $0x1632,(%esp)
     9d3:	e8 48 fb ff ff       	call   520 <panic>
  }
  nulterminate(cmd);
     9d8:	89 34 24             	mov    %esi,(%esp)
     9db:	e8 20 f6 ff ff       	call   0 <nulterminate>
  return cmd;
}
     9e0:	83 c4 10             	add    $0x10,%esp
     9e3:	89 f0                	mov    %esi,%eax
     9e5:	5b                   	pop    %ebx
     9e6:	5e                   	pop    %esi
     9e7:	5d                   	pop    %ebp
     9e8:	c3                   	ret    
     9e9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

000009f0 <fork1>:
  exit();
}

int
fork1(void)
{
     9f0:	55                   	push   %ebp
     9f1:	89 e5                	mov    %esp,%ebp
     9f3:	83 ec 28             	sub    $0x28,%esp
  int pid;
  
  pid = fork();
     9f6:	e8 05 07 00 00       	call   1100 <fork>
  if(pid == -1)
     9fb:	83 f8 ff             	cmp    $0xffffffff,%eax
     9fe:	74 08                	je     a08 <fork1+0x18>
    panic("fork");
  return pid;
}
     a00:	c9                   	leave  
     a01:	c3                   	ret    
     a02:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
{
  int pid;
  
  pid = fork();
  if(pid == -1)
    panic("fork");
     a08:	c7 04 24 7d 16 00 00 	movl   $0x167d,(%esp)
     a0f:	89 45 f4             	mov    %eax,-0xc(%ebp)
     a12:	e8 09 fb ff ff       	call   520 <panic>
     a17:	8b 45 f4             	mov    -0xc(%ebp),%eax
  return pid;
}
     a1a:	c9                   	leave  
     a1b:	c3                   	ret    
     a1c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00000a20 <readAndParse>:

//our code

void
readAndParse(void)
{
     a20:	55                   	push   %ebp
     a21:	89 e5                	mov    %esp,%ebp
     a23:	57                   	push   %edi
     a24:	56                   	push   %esi
     a25:	53                   	push   %ebx
  counter = 0;
  bufCount = 0;
  int ourEOF;
  int i;

  pEnvFile = open(ENVVARIABLE, O_RDONLY);
     a26:	31 db                	xor    %ebx,%ebx

//our code

void
readAndParse(void)
{
     a28:	83 ec 2c             	sub    $0x2c,%esp
  counter = 0;
  bufCount = 0;
  int ourEOF;
  int i;

  pEnvFile = open(ENVVARIABLE, O_RDONLY);
     a2b:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     a32:	00 
     a33:	c7 04 24 82 16 00 00 	movl   $0x1682,(%esp)
     a3a:	e8 09 07 00 00       	call   1148 <open>
     a3f:	89 c7                	mov    %eax,%edi
     a41:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

  for (i=0 ; i<6 ; i ++){
	  ourEOF = read(pEnvFile, c, 1);
     a48:	8d 45 e7             	lea    -0x19(%ebp),%eax
  int ourEOF;
  int i;

  pEnvFile = open(ENVVARIABLE, O_RDONLY);

  for (i=0 ; i<6 ; i ++){
     a4b:	83 c3 01             	add    $0x1,%ebx
	  ourEOF = read(pEnvFile, c, 1);
     a4e:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     a55:	00 
     a56:	89 44 24 04          	mov    %eax,0x4(%esp)
     a5a:	89 3c 24             	mov    %edi,(%esp)
     a5d:	e8 be 06 00 00       	call   1120 <read>
  int ourEOF;
  int i;

  pEnvFile = open(ENVVARIABLE, O_RDONLY);

  for (i=0 ; i<6 ; i ++){
     a62:	83 fb 06             	cmp    $0x6,%ebx
	  ourEOF = read(pEnvFile, c, 1);
     a65:	89 c6                	mov    %eax,%esi
  int ourEOF;
  int i;

  pEnvFile = open(ENVVARIABLE, O_RDONLY);

  for (i=0 ; i<6 ; i ++){
     a67:	75 df                	jne    a48 <readAndParse+0x28>
     a69:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
	  ourEOF = read(pEnvFile, c, 1);
  }
  	while(ourEOF > 0){
     a70:	85 f6                	test   %esi,%esi
     a72:	7e 54                	jle    ac8 <readAndParse+0xa8>
			ourEOF = read(pEnvFile, c, 1);
				
		}
	
		paths[numOfDirs][bufCount] = 0;//end of path name
		numOfDirs = numOfDirs + 1;
     a74:	31 db                	xor    %ebx,%ebx
     a76:	66 90                	xchg   %ax,%ax
  for (i=0 ; i<6 ; i ++){
	  ourEOF = read(pEnvFile, c, 1);
  }
  	while(ourEOF > 0){
			
		while ((ourEOF > 0) && (*c != ':')){
     a78:	0f b6 45 e7          	movzbl -0x19(%ebp),%eax
     a7c:	3c 3a                	cmp    $0x3a,%al
     a7e:	74 58                	je     ad8 <readAndParse+0xb8>
				
			paths[numOfDirs][bufCount] = *c;
     a80:	8b 15 84 17 00 00    	mov    0x1784,%edx
			bufCount = bufCount + 1;
			ourEOF = read(pEnvFile, c, 1);
     a86:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     a8d:	00 
     a8e:	89 3c 24             	mov    %edi,(%esp)
  }
  	while(ourEOF > 0){
			
		while ((ourEOF > 0) && (*c != ':')){
				
			paths[numOfDirs][bufCount] = *c;
     a91:	8d 14 92             	lea    (%edx,%edx,4),%edx
     a94:	88 84 93 a0 17 00 00 	mov    %al,0x17a0(%ebx,%edx,4)
			bufCount = bufCount + 1;
			ourEOF = read(pEnvFile, c, 1);
     a9b:	8d 45 e7             	lea    -0x19(%ebp),%eax
  	while(ourEOF > 0){
			
		while ((ourEOF > 0) && (*c != ':')){
				
			paths[numOfDirs][bufCount] = *c;
			bufCount = bufCount + 1;
     a9e:	83 c3 01             	add    $0x1,%ebx
			ourEOF = read(pEnvFile, c, 1);
     aa1:	89 44 24 04          	mov    %eax,0x4(%esp)
     aa5:	e8 76 06 00 00       	call   1120 <read>
  for (i=0 ; i<6 ; i ++){
	  ourEOF = read(pEnvFile, c, 1);
  }
  	while(ourEOF > 0){
			
		while ((ourEOF > 0) && (*c != ':')){
     aaa:	85 c0                	test   %eax,%eax
				
			paths[numOfDirs][bufCount] = *c;
			bufCount = bufCount + 1;
			ourEOF = read(pEnvFile, c, 1);
     aac:	89 c6                	mov    %eax,%esi
  for (i=0 ; i<6 ; i ++){
	  ourEOF = read(pEnvFile, c, 1);
  }
  	while(ourEOF > 0){
			
		while ((ourEOF > 0) && (*c != ':')){
     aae:	7f c8                	jg     a78 <readAndParse+0x58>
			bufCount = bufCount + 1;
			ourEOF = read(pEnvFile, c, 1);
				
		}
	
		paths[numOfDirs][bufCount] = 0;//end of path name
     ab0:	a1 84 17 00 00       	mov    0x1784,%eax
     ab5:	8d 14 80             	lea    (%eax,%eax,4),%edx
		numOfDirs = numOfDirs + 1;
     ab8:	83 c0 01             	add    $0x1,%eax
			bufCount = bufCount + 1;
			ourEOF = read(pEnvFile, c, 1);
				
		}
	
		paths[numOfDirs][bufCount] = 0;//end of path name
     abb:	c6 84 93 a0 17 00 00 	movb   $0x0,0x17a0(%ebx,%edx,4)
     ac2:	00 
		numOfDirs = numOfDirs + 1;
     ac3:	a3 84 17 00 00       	mov    %eax,0x1784
		bufCount = 0;
		if (ourEOF > 0){
			read(pEnvFile, c, 1);}
			
	}
  close(pEnvFile);
     ac8:	89 3c 24             	mov    %edi,(%esp)
     acb:	e8 60 06 00 00       	call   1130 <close>
}
     ad0:	83 c4 2c             	add    $0x2c,%esp
     ad3:	5b                   	pop    %ebx
     ad4:	5e                   	pop    %esi
     ad5:	5f                   	pop    %edi
     ad6:	5d                   	pop    %ebp
     ad7:	c3                   	ret    
			bufCount = bufCount + 1;
			ourEOF = read(pEnvFile, c, 1);
				
		}
	
		paths[numOfDirs][bufCount] = 0;//end of path name
     ad8:	a1 84 17 00 00       	mov    0x1784,%eax
		numOfDirs = numOfDirs + 1;
		bufCount = 0;
		if (ourEOF > 0){
			read(pEnvFile, c, 1);}
     add:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     ae4:	00 
     ae5:	89 3c 24             	mov    %edi,(%esp)
			bufCount = bufCount + 1;
			ourEOF = read(pEnvFile, c, 1);
				
		}
	
		paths[numOfDirs][bufCount] = 0;//end of path name
     ae8:	8d 14 80             	lea    (%eax,%eax,4),%edx
		numOfDirs = numOfDirs + 1;
     aeb:	83 c0 01             	add    $0x1,%eax
     aee:	a3 84 17 00 00       	mov    %eax,0x1784
		bufCount = 0;
		if (ourEOF > 0){
			read(pEnvFile, c, 1);}
     af3:	8d 45 e7             	lea    -0x19(%ebp),%eax
			bufCount = bufCount + 1;
			ourEOF = read(pEnvFile, c, 1);
				
		}
	
		paths[numOfDirs][bufCount] = 0;//end of path name
     af6:	c6 84 93 a0 17 00 00 	movb   $0x0,0x17a0(%ebx,%edx,4)
     afd:	00 
		numOfDirs = numOfDirs + 1;
		bufCount = 0;
		if (ourEOF > 0){
			read(pEnvFile, c, 1);}
     afe:	89 44 24 04          	mov    %eax,0x4(%esp)
     b02:	e8 19 06 00 00       	call   1120 <read>
     b07:	e9 64 ff ff ff       	jmp    a70 <readAndParse+0x50>
     b0c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00000b10 <getcmd>:
  exit();
}

int
getcmd(char *buf, int nbuf)
{
     b10:	55                   	push   %ebp
     b11:	89 e5                	mov    %esp,%ebp
     b13:	83 ec 18             	sub    $0x18,%esp
     b16:	89 5d f8             	mov    %ebx,-0x8(%ebp)
     b19:	8b 5d 08             	mov    0x8(%ebp),%ebx
     b1c:	89 75 fc             	mov    %esi,-0x4(%ebp)
     b1f:	8b 75 0c             	mov    0xc(%ebp),%esi
  printf(2, "$ ");
     b22:	c7 44 24 04 87 16 00 	movl   $0x1687,0x4(%esp)
     b29:	00 
     b2a:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     b31:	e8 2a 07 00 00       	call   1260 <printf>
  memset(buf, 0, nbuf);
     b36:	89 74 24 08          	mov    %esi,0x8(%esp)
     b3a:	89 1c 24             	mov    %ebx,(%esp)
     b3d:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     b44:	00 
     b45:	e8 36 04 00 00       	call   f80 <memset>
  gets(buf, nbuf);
     b4a:	89 74 24 04          	mov    %esi,0x4(%esp)
     b4e:	89 1c 24             	mov    %ebx,(%esp)
     b51:	e8 4a 05 00 00       	call   10a0 <gets>
  if(buf[0] == 0) // EOF
    return -1;
  return 0;
}
     b56:	8b 75 fc             	mov    -0x4(%ebp),%esi
getcmd(char *buf, int nbuf)
{
  printf(2, "$ ");
  memset(buf, 0, nbuf);
  gets(buf, nbuf);
  if(buf[0] == 0) // EOF
     b59:	80 3b 01             	cmpb   $0x1,(%ebx)
    return -1;
  return 0;
}
     b5c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
getcmd(char *buf, int nbuf)
{
  printf(2, "$ ");
  memset(buf, 0, nbuf);
  gets(buf, nbuf);
  if(buf[0] == 0) // EOF
     b5f:	19 c0                	sbb    %eax,%eax
    return -1;
  return 0;
}
     b61:	89 ec                	mov    %ebp,%esp
     b63:	5d                   	pop    %ebp
     b64:	c3                   	ret    
     b65:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     b69:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000b70 <runcmd>:


// Execute cmd.  Never returns.
void
runcmd(struct cmd *cmd)
{
     b70:	55                   	push   %ebp
     b71:	89 e5                	mov    %esp,%ebp
     b73:	57                   	push   %edi
     b74:	56                   	push   %esi
     b75:	53                   	push   %ebx
     b76:	83 ec 2c             	sub    $0x2c,%esp
     b79:	8b 75 08             	mov    0x8(%ebp),%esi
  struct execcmd *ecmd;
  struct listcmd *lcmd;
  struct pipecmd *pcmd;
  struct redircmd *rcmd;

  if(cmd == 0)
     b7c:	85 f6                	test   %esi,%esi
     b7e:	0f 84 ac 00 00 00    	je     c30 <runcmd+0xc0>
    exit();
  
  switch(cmd->type){
     b84:	83 3e 05             	cmpl   $0x5,(%esi)
     b87:	0f 86 ab 00 00 00    	jbe    c38 <runcmd+0xc8>
  default:
    panic("runcmd");
     b8d:	c7 04 24 8a 16 00 00 	movl   $0x168a,(%esp)
     b94:	e8 87 f9 ff ff       	call   520 <panic>

  case EXEC:
    ecmd = (struct execcmd*)cmd;
    if(ecmd->argv[0] == 0)
     b99:	8b 46 04             	mov    0x4(%esi),%eax
     b9c:	85 c0                	test   %eax,%eax
     b9e:	0f 84 8c 00 00 00    	je     c30 <runcmd+0xc0>
      exit();
    exec(ecmd->argv[0], ecmd->argv);
     ba4:	8d 7e 04             	lea    0x4(%esi),%edi
     ba7:	89 7c 24 04          	mov    %edi,0x4(%esp)
     bab:	89 04 24             	mov    %eax,(%esp)
     bae:	e8 8d 05 00 00       	call   1140 <exec>
    
 
    
    while (counter  < numOfDirs) {
     bb3:	83 3d 84 17 00 00 01 	cmpl   $0x1,0x1784
     bba:	7e 59                	jle    c15 <runcmd+0xa5>
     bbc:	bb 01 00 00 00       	mov    $0x1,%ebx
     bc1:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  	copyComm(ecmd->argv[0], counter);
     bc8:	89 5c 24 04          	mov    %ebx,0x4(%esp)
     bcc:	8b 46 04             	mov    0x4(%esi),%eax
	exec(tempComm, ecmd->argv);
	
	
	printf(2, "exec %s failed. No such file: %s\n",
 ecmd->argv[0], tempComm);
    	counter = counter + 1; 
     bcf:	83 c3 01             	add    $0x1,%ebx
    exec(ecmd->argv[0], ecmd->argv);
    
 
    
    while (counter  < numOfDirs) {
  	copyComm(ecmd->argv[0], counter);
     bd2:	89 04 24             	mov    %eax,(%esp)
     bd5:	e8 d6 f4 ff ff       	call   b0 <copyComm>
	exec(tempComm, ecmd->argv);
     bda:	89 7c 24 04          	mov    %edi,0x4(%esp)
     bde:	c7 04 24 40 19 00 00 	movl   $0x1940,(%esp)
     be5:	e8 56 05 00 00       	call   1140 <exec>
	
	
	printf(2, "exec %s failed. No such file: %s\n",
     bea:	c7 44 24 0c 40 19 00 	movl   $0x1940,0xc(%esp)
     bf1:	00 
     bf2:	8b 46 04             	mov    0x4(%esi),%eax
     bf5:	c7 44 24 04 cc 16 00 	movl   $0x16cc,0x4(%esp)
     bfc:	00 
     bfd:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     c04:	89 44 24 08          	mov    %eax,0x8(%esp)
     c08:	e8 53 06 00 00       	call   1260 <printf>
      exit();
    exec(ecmd->argv[0], ecmd->argv);
    
 
    
    while (counter  < numOfDirs) {
     c0d:	39 1d 84 17 00 00    	cmp    %ebx,0x1784
     c13:	7f b3                	jg     bc8 <runcmd+0x58>
	printf(2, "exec %s failed. No such file: %s\n",
 ecmd->argv[0], tempComm);
    	counter = counter + 1; 
    }
	    
    printf(2, "exec %s failed\n", ecmd->argv[0]);
     c15:	8b 46 04             	mov    0x4(%esi),%eax
     c18:	c7 44 24 04 91 16 00 	movl   $0x1691,0x4(%esp)
     c1f:	00 
     c20:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     c27:	89 44 24 08          	mov    %eax,0x8(%esp)
     c2b:	e8 30 06 00 00       	call   1260 <printf>
    bcmd = (struct backcmd*)cmd;
    if(fork1() == 0)
      runcmd(bcmd->cmd);
    break;
  }
  exit();
     c30:	e8 d3 04 00 00       	call   1108 <exit>
     c35:	8d 76 00             	lea    0x0(%esi),%esi
  struct redircmd *rcmd;

  if(cmd == 0)
    exit();
  
  switch(cmd->type){
     c38:	8b 06                	mov    (%esi),%eax
     c3a:	ff 24 85 f8 15 00 00 	jmp    *0x15f8(,%eax,4)
     c41:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    wait();
    break;
    
  case BACK:
    bcmd = (struct backcmd*)cmd;
    if(fork1() == 0)
     c48:	e8 a3 fd ff ff       	call   9f0 <fork1>
     c4d:	85 c0                	test   %eax,%eax
     c4f:	90                   	nop
     c50:	0f 84 a7 00 00 00    	je     cfd <runcmd+0x18d>
      runcmd(bcmd->cmd);
    break;
  }
  exit();
     c56:	e8 ad 04 00 00       	call   1108 <exit>
     c5b:	90                   	nop
     c5c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    runcmd(rcmd->cmd);
    break;

  case LIST:
    lcmd = (struct listcmd*)cmd;
    if(fork1() == 0)
     c60:	e8 8b fd ff ff       	call   9f0 <fork1>
     c65:	85 c0                	test   %eax,%eax
     c67:	0f 84 a3 00 00 00    	je     d10 <runcmd+0x1a0>
     c6d:	8d 76 00             	lea    0x0(%esi),%esi
      runcmd(lcmd->left);
    wait();
     c70:	e8 9b 04 00 00       	call   1110 <wait>
    runcmd(lcmd->right);
     c75:	8b 46 08             	mov    0x8(%esi),%eax
     c78:	89 04 24             	mov    %eax,(%esp)
     c7b:	e8 f0 fe ff ff       	call   b70 <runcmd>
    bcmd = (struct backcmd*)cmd;
    if(fork1() == 0)
      runcmd(bcmd->cmd);
    break;
  }
  exit();
     c80:	e8 83 04 00 00       	call   1108 <exit>
     c85:	8d 76 00             	lea    0x0(%esi),%esi
    runcmd(lcmd->right);
    break;

  case PIPE:
    pcmd = (struct pipecmd*)cmd;
    if(pipe(p) < 0)
     c88:	8d 45 e0             	lea    -0x20(%ebp),%eax
     c8b:	89 04 24             	mov    %eax,(%esp)
     c8e:	e8 85 04 00 00       	call   1118 <pipe>
     c93:	85 c0                	test   %eax,%eax
     c95:	0f 88 25 01 00 00    	js     dc0 <runcmd+0x250>
      panic("pipe");
    if(fork1() == 0){
     c9b:	e8 50 fd ff ff       	call   9f0 <fork1>
     ca0:	85 c0                	test   %eax,%eax
     ca2:	0f 84 b8 00 00 00    	je     d60 <runcmd+0x1f0>
      dup(p[1]);
      close(p[0]);
      close(p[1]);
      runcmd(pcmd->left);
    }
    if(fork1() == 0){
     ca8:	e8 43 fd ff ff       	call   9f0 <fork1>
     cad:	85 c0                	test   %eax,%eax
     caf:	90                   	nop
     cb0:	74 6e                	je     d20 <runcmd+0x1b0>
      dup(p[0]);
      close(p[0]);
      close(p[1]);
      runcmd(pcmd->right);
    }
    close(p[0]);
     cb2:	8b 45 e0             	mov    -0x20(%ebp),%eax
     cb5:	89 04 24             	mov    %eax,(%esp)
     cb8:	e8 73 04 00 00       	call   1130 <close>
    close(p[1]);
     cbd:	8b 45 e4             	mov    -0x1c(%ebp),%eax
     cc0:	89 04 24             	mov    %eax,(%esp)
     cc3:	e8 68 04 00 00       	call   1130 <close>
    wait();
     cc8:	e8 43 04 00 00       	call   1110 <wait>
    wait();
     ccd:	e8 3e 04 00 00       	call   1110 <wait>
    bcmd = (struct backcmd*)cmd;
    if(fork1() == 0)
      runcmd(bcmd->cmd);
    break;
  }
  exit();
     cd2:	e8 31 04 00 00       	call   1108 <exit>
     cd7:	90                   	nop
    printf(2, "exec %s failed\n", ecmd->argv[0]);
    break;

  case REDIR:
    rcmd = (struct redircmd*)cmd;
    close(rcmd->fd);
     cd8:	8b 46 14             	mov    0x14(%esi),%eax
     cdb:	89 04 24             	mov    %eax,(%esp)
     cde:	e8 4d 04 00 00       	call   1130 <close>
    if(open(rcmd->file, rcmd->mode) < 0){
     ce3:	8b 46 10             	mov    0x10(%esi),%eax
     ce6:	89 44 24 04          	mov    %eax,0x4(%esp)
     cea:	8b 46 08             	mov    0x8(%esi),%eax
     ced:	89 04 24             	mov    %eax,(%esp)
     cf0:	e8 53 04 00 00       	call   1148 <open>
     cf5:	85 c0                	test   %eax,%eax
     cf7:	0f 88 a3 00 00 00    	js     da0 <runcmd+0x230>
    break;
    
  case BACK:
    bcmd = (struct backcmd*)cmd;
    if(fork1() == 0)
      runcmd(bcmd->cmd);
     cfd:	8b 46 04             	mov    0x4(%esi),%eax
     d00:	89 04 24             	mov    %eax,(%esp)
     d03:	e8 68 fe ff ff       	call   b70 <runcmd>
    break;
  }
  exit();
     d08:	e8 fb 03 00 00       	call   1108 <exit>
     d0d:	8d 76 00             	lea    0x0(%esi),%esi
    break;

  case LIST:
    lcmd = (struct listcmd*)cmd;
    if(fork1() == 0)
      runcmd(lcmd->left);
     d10:	8b 46 04             	mov    0x4(%esi),%eax
     d13:	89 04 24             	mov    %eax,(%esp)
     d16:	e8 55 fe ff ff       	call   b70 <runcmd>
     d1b:	e9 4d ff ff ff       	jmp    c6d <runcmd+0xfd>
      close(p[0]);
      close(p[1]);
      runcmd(pcmd->left);
    }
    if(fork1() == 0){
      close(0);
     d20:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
     d27:	e8 04 04 00 00       	call   1130 <close>
      dup(p[0]);
     d2c:	8b 45 e0             	mov    -0x20(%ebp),%eax
     d2f:	89 04 24             	mov    %eax,(%esp)
     d32:	e8 49 04 00 00       	call   1180 <dup>
      close(p[0]);
     d37:	8b 45 e0             	mov    -0x20(%ebp),%eax
     d3a:	89 04 24             	mov    %eax,(%esp)
     d3d:	e8 ee 03 00 00       	call   1130 <close>
      close(p[1]);
     d42:	8b 45 e4             	mov    -0x1c(%ebp),%eax
     d45:	89 04 24             	mov    %eax,(%esp)
     d48:	e8 e3 03 00 00       	call   1130 <close>
      runcmd(pcmd->right);
     d4d:	8b 46 08             	mov    0x8(%esi),%eax
     d50:	89 04 24             	mov    %eax,(%esp)
     d53:	e8 18 fe ff ff       	call   b70 <runcmd>
     d58:	e9 55 ff ff ff       	jmp    cb2 <runcmd+0x142>
     d5d:	8d 76 00             	lea    0x0(%esi),%esi
  case PIPE:
    pcmd = (struct pipecmd*)cmd;
    if(pipe(p) < 0)
      panic("pipe");
    if(fork1() == 0){
      close(1);
     d60:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
     d67:	e8 c4 03 00 00       	call   1130 <close>
      dup(p[1]);
     d6c:	8b 45 e4             	mov    -0x1c(%ebp),%eax
     d6f:	89 04 24             	mov    %eax,(%esp)
     d72:	e8 09 04 00 00       	call   1180 <dup>
      close(p[0]);
     d77:	8b 45 e0             	mov    -0x20(%ebp),%eax
     d7a:	89 04 24             	mov    %eax,(%esp)
     d7d:	e8 ae 03 00 00       	call   1130 <close>
      close(p[1]);
     d82:	8b 45 e4             	mov    -0x1c(%ebp),%eax
     d85:	89 04 24             	mov    %eax,(%esp)
     d88:	e8 a3 03 00 00       	call   1130 <close>
      runcmd(pcmd->left);
     d8d:	8b 46 04             	mov    0x4(%esi),%eax
     d90:	89 04 24             	mov    %eax,(%esp)
     d93:	e8 d8 fd ff ff       	call   b70 <runcmd>
     d98:	e9 0b ff ff ff       	jmp    ca8 <runcmd+0x138>
     d9d:	8d 76 00             	lea    0x0(%esi),%esi

  case REDIR:
    rcmd = (struct redircmd*)cmd;
    close(rcmd->fd);
    if(open(rcmd->file, rcmd->mode) < 0){
      printf(2, "open %s failed\n", rcmd->file);
     da0:	8b 46 08             	mov    0x8(%esi),%eax
     da3:	c7 44 24 04 a1 16 00 	movl   $0x16a1,0x4(%esp)
     daa:	00 
     dab:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     db2:	89 44 24 08          	mov    %eax,0x8(%esp)
     db6:	e8 a5 04 00 00       	call   1260 <printf>
      exit();
     dbb:	e8 48 03 00 00       	call   1108 <exit>
    break;

  case PIPE:
    pcmd = (struct pipecmd*)cmd;
    if(pipe(p) < 0)
      panic("pipe");
     dc0:	c7 04 24 b1 16 00 00 	movl   $0x16b1,(%esp)
     dc7:	e8 54 f7 ff ff       	call   520 <panic>
     dcc:	e9 ca fe ff ff       	jmp    c9b <runcmd+0x12b>
     dd1:	eb 0d                	jmp    de0 <main>
     dd3:	90                   	nop
     dd4:	90                   	nop
     dd5:	90                   	nop
     dd6:	90                   	nop
     dd7:	90                   	nop
     dd8:	90                   	nop
     dd9:	90                   	nop
     dda:	90                   	nop
     ddb:	90                   	nop
     ddc:	90                   	nop
     ddd:	90                   	nop
     dde:	90                   	nop
     ddf:	90                   	nop

00000de0 <main>:



int
main(void)
{
     de0:	55                   	push   %ebp
     de1:	89 e5                	mov    %esp,%ebp
     de3:	83 e4 f0             	and    $0xfffffff0,%esp
     de6:	83 ec 10             	sub    $0x10,%esp
     de9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

//   readAndParse();
//  printTest(envPaths);

  // Assumes three file descriptors open.
  while((fd = open("console", O_RDWR)) >= 0){
     df0:	c7 44 24 04 02 00 00 	movl   $0x2,0x4(%esp)
     df7:	00 
     df8:	c7 04 24 b6 16 00 00 	movl   $0x16b6,(%esp)
     dff:	e8 44 03 00 00       	call   1148 <open>
     e04:	85 c0                	test   %eax,%eax
     e06:	78 0d                	js     e15 <main+0x35>
    if(fd >= 3){
     e08:	83 f8 02             	cmp    $0x2,%eax
     e0b:	7e e3                	jle    df0 <main+0x10>
      close(fd);
     e0d:	89 04 24             	mov    %eax,(%esp)
     e10:	e8 1b 03 00 00       	call   1130 <close>
      break;
    }
  }

  readAndParse();
     e15:	e8 06 fc ff ff       	call   a20 <readAndParse>
  printTest();
     e1a:	e8 21 f3 ff ff       	call   140 <printTest>
     e1f:	90                   	nop
  
  
  
  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
     e20:	eb 13                	jmp    e35 <main+0x55>
     e22:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
     e28:	90                   	nop
     e29:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
        printf(2, "cannot cd %s\n", buf+3);
      continue;
    }
    if(fork1() == 0)
      runcmd(parsecmd(buf));
    wait();
     e30:	e8 db 02 00 00       	call   1110 <wait>
  printTest();
  
  
  
  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
     e35:	c7 44 24 04 64 00 00 	movl   $0x64,0x4(%esp)
     e3c:	00 
     e3d:	c7 04 24 20 17 00 00 	movl   $0x1720,(%esp)
     e44:	e8 c7 fc ff ff       	call   b10 <getcmd>
     e49:	85 c0                	test   %eax,%eax
     e4b:	0f 88 87 00 00 00    	js     ed8 <main+0xf8>
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
     e51:	80 3d 20 17 00 00 63 	cmpb   $0x63,0x1720
     e58:	75 09                	jne    e63 <main+0x83>
     e5a:	80 3d 21 17 00 00 64 	cmpb   $0x64,0x1721
     e61:	74 25                	je     e88 <main+0xa8>
      buf[strlen(buf)-1] = 0;  // chop \n
      if(chdir(buf+3) < 0)
        printf(2, "cannot cd %s\n", buf+3);
      continue;
    }
    if(fork1() == 0)
     e63:	e8 88 fb ff ff       	call   9f0 <fork1>
     e68:	85 c0                	test   %eax,%eax
     e6a:	75 bc                	jne    e28 <main+0x48>
      runcmd(parsecmd(buf));
     e6c:	c7 04 24 20 17 00 00 	movl   $0x1720,(%esp)
     e73:	e8 f8 fa ff ff       	call   970 <parsecmd>
     e78:	89 04 24             	mov    %eax,(%esp)
     e7b:	e8 f0 fc ff ff       	call   b70 <runcmd>
     e80:	eb a6                	jmp    e28 <main+0x48>
     e82:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  
  
  
  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
     e88:	80 3d 22 17 00 00 20 	cmpb   $0x20,0x1722
     e8f:	75 d2                	jne    e63 <main+0x83>
      // Clumsy but will have to do for now.
      // Chdir has no effect on the parent if run in the child.
      buf[strlen(buf)-1] = 0;  // chop \n
     e91:	c7 04 24 20 17 00 00 	movl   $0x1720,(%esp)
     e98:	e8 c3 00 00 00       	call   f60 <strlen>
      if(chdir(buf+3) < 0)
     e9d:	c7 04 24 23 17 00 00 	movl   $0x1723,(%esp)
  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      // Clumsy but will have to do for now.
      // Chdir has no effect on the parent if run in the child.
      buf[strlen(buf)-1] = 0;  // chop \n
     ea4:	c6 80 1f 17 00 00 00 	movb   $0x0,0x171f(%eax)
      if(chdir(buf+3) < 0)
     eab:	e8 c8 02 00 00       	call   1178 <chdir>
     eb0:	85 c0                	test   %eax,%eax
     eb2:	79 81                	jns    e35 <main+0x55>
        printf(2, "cannot cd %s\n", buf+3);
     eb4:	c7 44 24 08 23 17 00 	movl   $0x1723,0x8(%esp)
     ebb:	00 
     ebc:	c7 44 24 04 be 16 00 	movl   $0x16be,0x4(%esp)
     ec3:	00 
     ec4:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     ecb:	e8 90 03 00 00       	call   1260 <printf>
     ed0:	e9 60 ff ff ff       	jmp    e35 <main+0x55>
     ed5:	8d 76 00             	lea    0x0(%esi),%esi
    }
    if(fork1() == 0)
      runcmd(parsecmd(buf));
    wait();
  }
  exit();
     ed8:	e8 2b 02 00 00       	call   1108 <exit>
     edd:	90                   	nop
     ede:	90                   	nop
     edf:	90                   	nop

00000ee0 <strcpy>:
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
     ee0:	55                   	push   %ebp
     ee1:	31 d2                	xor    %edx,%edx
     ee3:	89 e5                	mov    %esp,%ebp
     ee5:	8b 45 08             	mov    0x8(%ebp),%eax
     ee8:	53                   	push   %ebx
     ee9:	8b 5d 0c             	mov    0xc(%ebp),%ebx
     eec:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
     ef0:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
     ef4:	88 0c 10             	mov    %cl,(%eax,%edx,1)
     ef7:	83 c2 01             	add    $0x1,%edx
     efa:	84 c9                	test   %cl,%cl
     efc:	75 f2                	jne    ef0 <strcpy+0x10>
    ;
  return os;
}
     efe:	5b                   	pop    %ebx
     eff:	5d                   	pop    %ebp
     f00:	c3                   	ret    
     f01:	eb 0d                	jmp    f10 <strcmp>
     f03:	90                   	nop
     f04:	90                   	nop
     f05:	90                   	nop
     f06:	90                   	nop
     f07:	90                   	nop
     f08:	90                   	nop
     f09:	90                   	nop
     f0a:	90                   	nop
     f0b:	90                   	nop
     f0c:	90                   	nop
     f0d:	90                   	nop
     f0e:	90                   	nop
     f0f:	90                   	nop

00000f10 <strcmp>:

int
strcmp(const char *p, const char *q)
{
     f10:	55                   	push   %ebp
     f11:	89 e5                	mov    %esp,%ebp
     f13:	53                   	push   %ebx
     f14:	8b 4d 08             	mov    0x8(%ebp),%ecx
     f17:	8b 55 0c             	mov    0xc(%ebp),%edx
  while(*p && *p == *q)
     f1a:	0f b6 01             	movzbl (%ecx),%eax
     f1d:	84 c0                	test   %al,%al
     f1f:	75 14                	jne    f35 <strcmp+0x25>
     f21:	eb 25                	jmp    f48 <strcmp+0x38>
     f23:	90                   	nop
     f24:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    p++, q++;
     f28:	83 c1 01             	add    $0x1,%ecx
     f2b:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
     f2e:	0f b6 01             	movzbl (%ecx),%eax
     f31:	84 c0                	test   %al,%al
     f33:	74 13                	je     f48 <strcmp+0x38>
     f35:	0f b6 1a             	movzbl (%edx),%ebx
     f38:	38 d8                	cmp    %bl,%al
     f3a:	74 ec                	je     f28 <strcmp+0x18>
     f3c:	0f b6 db             	movzbl %bl,%ebx
     f3f:	0f b6 c0             	movzbl %al,%eax
     f42:	29 d8                	sub    %ebx,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
}
     f44:	5b                   	pop    %ebx
     f45:	5d                   	pop    %ebp
     f46:	c3                   	ret    
     f47:	90                   	nop
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
     f48:	0f b6 1a             	movzbl (%edx),%ebx
     f4b:	31 c0                	xor    %eax,%eax
     f4d:	0f b6 db             	movzbl %bl,%ebx
     f50:	29 d8                	sub    %ebx,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
}
     f52:	5b                   	pop    %ebx
     f53:	5d                   	pop    %ebp
     f54:	c3                   	ret    
     f55:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     f59:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000f60 <strlen>:

uint
strlen(char *s)
{
     f60:	55                   	push   %ebp
  int n;

  for(n = 0; s[n]; n++)
     f61:	31 d2                	xor    %edx,%edx
  return (uchar)*p - (uchar)*q;
}

uint
strlen(char *s)
{
     f63:	89 e5                	mov    %esp,%ebp
  int n;

  for(n = 0; s[n]; n++)
     f65:	31 c0                	xor    %eax,%eax
  return (uchar)*p - (uchar)*q;
}

uint
strlen(char *s)
{
     f67:	8b 4d 08             	mov    0x8(%ebp),%ecx
  int n;

  for(n = 0; s[n]; n++)
     f6a:	80 39 00             	cmpb   $0x0,(%ecx)
     f6d:	74 0c                	je     f7b <strlen+0x1b>
     f6f:	90                   	nop
     f70:	83 c2 01             	add    $0x1,%edx
     f73:	80 3c 11 00          	cmpb   $0x0,(%ecx,%edx,1)
     f77:	89 d0                	mov    %edx,%eax
     f79:	75 f5                	jne    f70 <strlen+0x10>
    ;
  return n;
}
     f7b:	5d                   	pop    %ebp
     f7c:	c3                   	ret    
     f7d:	8d 76 00             	lea    0x0(%esi),%esi

00000f80 <memset>:

void*
memset(void *dst, int c, uint n)
{
     f80:	55                   	push   %ebp
     f81:	89 e5                	mov    %esp,%ebp
     f83:	8b 55 08             	mov    0x8(%ebp),%edx
     f86:	57                   	push   %edi
}

static inline void
stosb(void *addr, int data, int cnt)
{
  asm volatile("cld; rep stosb" :
     f87:	8b 4d 10             	mov    0x10(%ebp),%ecx
     f8a:	8b 45 0c             	mov    0xc(%ebp),%eax
     f8d:	89 d7                	mov    %edx,%edi
     f8f:	fc                   	cld    
     f90:	f3 aa                	rep stos %al,%es:(%edi)
  stosb(dst, c, n);
  return dst;
}
     f92:	89 d0                	mov    %edx,%eax
     f94:	5f                   	pop    %edi
     f95:	5d                   	pop    %ebp
     f96:	c3                   	ret    
     f97:	89 f6                	mov    %esi,%esi
     f99:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000fa0 <strchr>:

char*
strchr(const char *s, char c)
{
     fa0:	55                   	push   %ebp
     fa1:	89 e5                	mov    %esp,%ebp
     fa3:	8b 45 08             	mov    0x8(%ebp),%eax
     fa6:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  for(; *s; s++)
     faa:	0f b6 10             	movzbl (%eax),%edx
     fad:	84 d2                	test   %dl,%dl
     faf:	75 11                	jne    fc2 <strchr+0x22>
     fb1:	eb 15                	jmp    fc8 <strchr+0x28>
     fb3:	90                   	nop
     fb4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     fb8:	83 c0 01             	add    $0x1,%eax
     fbb:	0f b6 10             	movzbl (%eax),%edx
     fbe:	84 d2                	test   %dl,%dl
     fc0:	74 06                	je     fc8 <strchr+0x28>
    if(*s == c)
     fc2:	38 ca                	cmp    %cl,%dl
     fc4:	75 f2                	jne    fb8 <strchr+0x18>
      return (char*) s;
  return 0;
}
     fc6:	5d                   	pop    %ebp
     fc7:	c3                   	ret    
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
     fc8:	31 c0                	xor    %eax,%eax
    if(*s == c)
      return (char*) s;
  return 0;
}
     fca:	5d                   	pop    %ebp
     fcb:	90                   	nop
     fcc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     fd0:	c3                   	ret    
     fd1:	eb 0d                	jmp    fe0 <atoi>
     fd3:	90                   	nop
     fd4:	90                   	nop
     fd5:	90                   	nop
     fd6:	90                   	nop
     fd7:	90                   	nop
     fd8:	90                   	nop
     fd9:	90                   	nop
     fda:	90                   	nop
     fdb:	90                   	nop
     fdc:	90                   	nop
     fdd:	90                   	nop
     fde:	90                   	nop
     fdf:	90                   	nop

00000fe0 <atoi>:
  return r;
}

int
atoi(const char *s)
{
     fe0:	55                   	push   %ebp
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
     fe1:	31 c0                	xor    %eax,%eax
  return r;
}

int
atoi(const char *s)
{
     fe3:	89 e5                	mov    %esp,%ebp
     fe5:	8b 4d 08             	mov    0x8(%ebp),%ecx
     fe8:	53                   	push   %ebx
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
     fe9:	0f b6 11             	movzbl (%ecx),%edx
     fec:	8d 5a d0             	lea    -0x30(%edx),%ebx
     fef:	80 fb 09             	cmp    $0x9,%bl
     ff2:	77 1c                	ja     1010 <atoi+0x30>
     ff4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    n = n*10 + *s++ - '0';
     ff8:	0f be d2             	movsbl %dl,%edx
     ffb:	83 c1 01             	add    $0x1,%ecx
     ffe:	8d 04 80             	lea    (%eax,%eax,4),%eax
    1001:	8d 44 42 d0          	lea    -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
    1005:	0f b6 11             	movzbl (%ecx),%edx
    1008:	8d 5a d0             	lea    -0x30(%edx),%ebx
    100b:	80 fb 09             	cmp    $0x9,%bl
    100e:	76 e8                	jbe    ff8 <atoi+0x18>
    n = n*10 + *s++ - '0';
  return n;
}
    1010:	5b                   	pop    %ebx
    1011:	5d                   	pop    %ebp
    1012:	c3                   	ret    
    1013:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    1019:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00001020 <memmove>:

void*
memmove(void *vdst, void *vsrc, int n)
{
    1020:	55                   	push   %ebp
    1021:	89 e5                	mov    %esp,%ebp
    1023:	56                   	push   %esi
    1024:	8b 45 08             	mov    0x8(%ebp),%eax
    1027:	53                   	push   %ebx
    1028:	8b 5d 10             	mov    0x10(%ebp),%ebx
    102b:	8b 75 0c             	mov    0xc(%ebp),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
    102e:	85 db                	test   %ebx,%ebx
    1030:	7e 14                	jle    1046 <memmove+0x26>
    n = n*10 + *s++ - '0';
  return n;
}

void*
memmove(void *vdst, void *vsrc, int n)
    1032:	31 d2                	xor    %edx,%edx
    1034:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
    *dst++ = *src++;
    1038:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
    103c:	88 0c 10             	mov    %cl,(%eax,%edx,1)
    103f:	83 c2 01             	add    $0x1,%edx
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
    1042:	39 da                	cmp    %ebx,%edx
    1044:	75 f2                	jne    1038 <memmove+0x18>
    *dst++ = *src++;
  return vdst;
}
    1046:	5b                   	pop    %ebx
    1047:	5e                   	pop    %esi
    1048:	5d                   	pop    %ebp
    1049:	c3                   	ret    
    104a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

00001050 <stat>:
  return buf;
}

int
stat(char *n, struct stat *st)
{
    1050:	55                   	push   %ebp
    1051:	89 e5                	mov    %esp,%ebp
    1053:	83 ec 18             	sub    $0x18,%esp
  int fd;
  int r;

  fd = open(n, O_RDONLY);
    1056:	8b 45 08             	mov    0x8(%ebp),%eax
  return buf;
}

int
stat(char *n, struct stat *st)
{
    1059:	89 5d f8             	mov    %ebx,-0x8(%ebp)
    105c:	89 75 fc             	mov    %esi,-0x4(%ebp)
  int fd;
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    105f:	be ff ff ff ff       	mov    $0xffffffff,%esi
stat(char *n, struct stat *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
    1064:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
    106b:	00 
    106c:	89 04 24             	mov    %eax,(%esp)
    106f:	e8 d4 00 00 00       	call   1148 <open>
  if(fd < 0)
    1074:	85 c0                	test   %eax,%eax
stat(char *n, struct stat *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
    1076:	89 c3                	mov    %eax,%ebx
  if(fd < 0)
    1078:	78 19                	js     1093 <stat+0x43>
    return -1;
  r = fstat(fd, st);
    107a:	8b 45 0c             	mov    0xc(%ebp),%eax
    107d:	89 1c 24             	mov    %ebx,(%esp)
    1080:	89 44 24 04          	mov    %eax,0x4(%esp)
    1084:	e8 d7 00 00 00       	call   1160 <fstat>
  close(fd);
    1089:	89 1c 24             	mov    %ebx,(%esp)
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
  r = fstat(fd, st);
    108c:	89 c6                	mov    %eax,%esi
  close(fd);
    108e:	e8 9d 00 00 00       	call   1130 <close>
  return r;
}
    1093:	89 f0                	mov    %esi,%eax
    1095:	8b 5d f8             	mov    -0x8(%ebp),%ebx
    1098:	8b 75 fc             	mov    -0x4(%ebp),%esi
    109b:	89 ec                	mov    %ebp,%esp
    109d:	5d                   	pop    %ebp
    109e:	c3                   	ret    
    109f:	90                   	nop

000010a0 <gets>:
  return 0;
}

char*
gets(char *buf, int max)
{
    10a0:	55                   	push   %ebp
    10a1:	89 e5                	mov    %esp,%ebp
    10a3:	57                   	push   %edi
    10a4:	56                   	push   %esi
    10a5:	31 f6                	xor    %esi,%esi
    10a7:	53                   	push   %ebx
    10a8:	83 ec 2c             	sub    $0x2c,%esp
    10ab:	8b 7d 08             	mov    0x8(%ebp),%edi
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
    10ae:	eb 06                	jmp    10b6 <gets+0x16>
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
    10b0:	3c 0a                	cmp    $0xa,%al
    10b2:	74 39                	je     10ed <gets+0x4d>
    10b4:	89 de                	mov    %ebx,%esi
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
    10b6:	8d 5e 01             	lea    0x1(%esi),%ebx
    10b9:	3b 5d 0c             	cmp    0xc(%ebp),%ebx
    10bc:	7d 31                	jge    10ef <gets+0x4f>
    cc = read(0, &c, 1);
    10be:	8d 45 e7             	lea    -0x19(%ebp),%eax
    10c1:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
    10c8:	00 
    10c9:	89 44 24 04          	mov    %eax,0x4(%esp)
    10cd:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
    10d4:	e8 47 00 00 00       	call   1120 <read>
    if(cc < 1)
    10d9:	85 c0                	test   %eax,%eax
    10db:	7e 12                	jle    10ef <gets+0x4f>
      break;
    buf[i++] = c;
    10dd:	0f b6 45 e7          	movzbl -0x19(%ebp),%eax
    10e1:	88 44 1f ff          	mov    %al,-0x1(%edi,%ebx,1)
    if(c == '\n' || c == '\r')
    10e5:	0f b6 45 e7          	movzbl -0x19(%ebp),%eax
    10e9:	3c 0d                	cmp    $0xd,%al
    10eb:	75 c3                	jne    10b0 <gets+0x10>
    10ed:	89 de                	mov    %ebx,%esi
      break;
  }
  buf[i] = '\0';
    10ef:	c6 04 37 00          	movb   $0x0,(%edi,%esi,1)
  return buf;
}
    10f3:	89 f8                	mov    %edi,%eax
    10f5:	83 c4 2c             	add    $0x2c,%esp
    10f8:	5b                   	pop    %ebx
    10f9:	5e                   	pop    %esi
    10fa:	5f                   	pop    %edi
    10fb:	5d                   	pop    %ebp
    10fc:	c3                   	ret    
    10fd:	90                   	nop
    10fe:	90                   	nop
    10ff:	90                   	nop

00001100 <fork>:
  name: \
    movl $SYS_ ## name, %eax; \
    int $T_SYSCALL; \
    ret

SYSCALL(fork)
    1100:	b8 01 00 00 00       	mov    $0x1,%eax
    1105:	cd 40                	int    $0x40
    1107:	c3                   	ret    

00001108 <exit>:
SYSCALL(exit)
    1108:	b8 02 00 00 00       	mov    $0x2,%eax
    110d:	cd 40                	int    $0x40
    110f:	c3                   	ret    

00001110 <wait>:
SYSCALL(wait)
    1110:	b8 03 00 00 00       	mov    $0x3,%eax
    1115:	cd 40                	int    $0x40
    1117:	c3                   	ret    

00001118 <pipe>:
SYSCALL(pipe)
    1118:	b8 04 00 00 00       	mov    $0x4,%eax
    111d:	cd 40                	int    $0x40
    111f:	c3                   	ret    

00001120 <read>:
SYSCALL(read)
    1120:	b8 06 00 00 00       	mov    $0x6,%eax
    1125:	cd 40                	int    $0x40
    1127:	c3                   	ret    

00001128 <write>:
SYSCALL(write)
    1128:	b8 05 00 00 00       	mov    $0x5,%eax
    112d:	cd 40                	int    $0x40
    112f:	c3                   	ret    

00001130 <close>:
SYSCALL(close)
    1130:	b8 07 00 00 00       	mov    $0x7,%eax
    1135:	cd 40                	int    $0x40
    1137:	c3                   	ret    

00001138 <kill>:
SYSCALL(kill)
    1138:	b8 08 00 00 00       	mov    $0x8,%eax
    113d:	cd 40                	int    $0x40
    113f:	c3                   	ret    

00001140 <exec>:
SYSCALL(exec)
    1140:	b8 09 00 00 00       	mov    $0x9,%eax
    1145:	cd 40                	int    $0x40
    1147:	c3                   	ret    

00001148 <open>:
SYSCALL(open)
    1148:	b8 0a 00 00 00       	mov    $0xa,%eax
    114d:	cd 40                	int    $0x40
    114f:	c3                   	ret    

00001150 <mknod>:
SYSCALL(mknod)
    1150:	b8 0b 00 00 00       	mov    $0xb,%eax
    1155:	cd 40                	int    $0x40
    1157:	c3                   	ret    

00001158 <unlink>:
SYSCALL(unlink)
    1158:	b8 0c 00 00 00       	mov    $0xc,%eax
    115d:	cd 40                	int    $0x40
    115f:	c3                   	ret    

00001160 <fstat>:
SYSCALL(fstat)
    1160:	b8 0d 00 00 00       	mov    $0xd,%eax
    1165:	cd 40                	int    $0x40
    1167:	c3                   	ret    

00001168 <link>:
SYSCALL(link)
    1168:	b8 0e 00 00 00       	mov    $0xe,%eax
    116d:	cd 40                	int    $0x40
    116f:	c3                   	ret    

00001170 <mkdir>:
SYSCALL(mkdir)
    1170:	b8 0f 00 00 00       	mov    $0xf,%eax
    1175:	cd 40                	int    $0x40
    1177:	c3                   	ret    

00001178 <chdir>:
SYSCALL(chdir)
    1178:	b8 10 00 00 00       	mov    $0x10,%eax
    117d:	cd 40                	int    $0x40
    117f:	c3                   	ret    

00001180 <dup>:
SYSCALL(dup)
    1180:	b8 11 00 00 00       	mov    $0x11,%eax
    1185:	cd 40                	int    $0x40
    1187:	c3                   	ret    

00001188 <getpid>:
SYSCALL(getpid)
    1188:	b8 12 00 00 00       	mov    $0x12,%eax
    118d:	cd 40                	int    $0x40
    118f:	c3                   	ret    

00001190 <sbrk>:
SYSCALL(sbrk)
    1190:	b8 13 00 00 00       	mov    $0x13,%eax
    1195:	cd 40                	int    $0x40
    1197:	c3                   	ret    

00001198 <sleep>:
SYSCALL(sleep)
    1198:	b8 14 00 00 00       	mov    $0x14,%eax
    119d:	cd 40                	int    $0x40
    119f:	c3                   	ret    

000011a0 <uptime>:
SYSCALL(uptime)
    11a0:	b8 15 00 00 00       	mov    $0x15,%eax
    11a5:	cd 40                	int    $0x40
    11a7:	c3                   	ret    

000011a8 <wait2>:
SYSCALL(wait2)
    11a8:	b8 16 00 00 00       	mov    $0x16,%eax
    11ad:	cd 40                	int    $0x40
    11af:	c3                   	ret    

000011b0 <nice>:
SYSCALL(nice)
    11b0:	b8 17 00 00 00       	mov    $0x17,%eax
    11b5:	cd 40                	int    $0x40
    11b7:	c3                   	ret    
    11b8:	90                   	nop
    11b9:	90                   	nop
    11ba:	90                   	nop
    11bb:	90                   	nop
    11bc:	90                   	nop
    11bd:	90                   	nop
    11be:	90                   	nop
    11bf:	90                   	nop

000011c0 <printint>:
  write(fd, &c, 1);
}

static void
printint(int fd, int xx, int base, int sgn)
{
    11c0:	55                   	push   %ebp
    11c1:	89 e5                	mov    %esp,%ebp
    11c3:	57                   	push   %edi
    11c4:	89 cf                	mov    %ecx,%edi
    11c6:	56                   	push   %esi
    11c7:	89 c6                	mov    %eax,%esi
    11c9:	53                   	push   %ebx
    11ca:	83 ec 4c             	sub    $0x4c,%esp
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
    11cd:	8b 4d 08             	mov    0x8(%ebp),%ecx
    11d0:	85 c9                	test   %ecx,%ecx
    11d2:	74 04                	je     11d8 <printint+0x18>
    11d4:	85 d2                	test   %edx,%edx
    11d6:	78 70                	js     1248 <printint+0x88>
    neg = 1;
    x = -xx;
  } else {
    x = xx;
    11d8:	89 d0                	mov    %edx,%eax
    11da:	c7 45 c4 00 00 00 00 	movl   $0x0,-0x3c(%ebp)
    11e1:	31 c9                	xor    %ecx,%ecx
    11e3:	8d 5d d7             	lea    -0x29(%ebp),%ebx
    11e6:	66 90                	xchg   %ax,%ax
  }

  i = 0;
  do{
    buf[i++] = digits[x % base];
    11e8:	31 d2                	xor    %edx,%edx
    11ea:	f7 f7                	div    %edi
    11ec:	0f b6 92 f7 16 00 00 	movzbl 0x16f7(%edx),%edx
    11f3:	88 14 0b             	mov    %dl,(%ebx,%ecx,1)
    11f6:	83 c1 01             	add    $0x1,%ecx
  }while((x /= base) != 0);
    11f9:	85 c0                	test   %eax,%eax
    11fb:	75 eb                	jne    11e8 <printint+0x28>
  if(neg)
    11fd:	8b 45 c4             	mov    -0x3c(%ebp),%eax
    1200:	85 c0                	test   %eax,%eax
    1202:	74 08                	je     120c <printint+0x4c>
    buf[i++] = '-';
    1204:	c6 44 0d d7 2d       	movb   $0x2d,-0x29(%ebp,%ecx,1)
    1209:	83 c1 01             	add    $0x1,%ecx

  while(--i >= 0)
    120c:	8d 79 ff             	lea    -0x1(%ecx),%edi
    120f:	01 fb                	add    %edi,%ebx
    1211:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    1218:	0f b6 03             	movzbl (%ebx),%eax
    121b:	83 ef 01             	sub    $0x1,%edi
    121e:	83 eb 01             	sub    $0x1,%ebx
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
    1221:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
    1228:	00 
    1229:	89 34 24             	mov    %esi,(%esp)
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
    122c:	88 45 e7             	mov    %al,-0x19(%ebp)
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
    122f:	8d 45 e7             	lea    -0x19(%ebp),%eax
    1232:	89 44 24 04          	mov    %eax,0x4(%esp)
    1236:	e8 ed fe ff ff       	call   1128 <write>
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
    123b:	83 ff ff             	cmp    $0xffffffff,%edi
    123e:	75 d8                	jne    1218 <printint+0x58>
    putc(fd, buf[i]);
}
    1240:	83 c4 4c             	add    $0x4c,%esp
    1243:	5b                   	pop    %ebx
    1244:	5e                   	pop    %esi
    1245:	5f                   	pop    %edi
    1246:	5d                   	pop    %ebp
    1247:	c3                   	ret    
  uint x;

  neg = 0;
  if(sgn && xx < 0){
    neg = 1;
    x = -xx;
    1248:	89 d0                	mov    %edx,%eax
    124a:	f7 d8                	neg    %eax
    124c:	c7 45 c4 01 00 00 00 	movl   $0x1,-0x3c(%ebp)
    1253:	eb 8c                	jmp    11e1 <printint+0x21>
    1255:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    1259:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00001260 <printf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
    1260:	55                   	push   %ebp
    1261:	89 e5                	mov    %esp,%ebp
    1263:	57                   	push   %edi
    1264:	56                   	push   %esi
    1265:	53                   	push   %ebx
    1266:	83 ec 3c             	sub    $0x3c,%esp
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    1269:	8b 45 0c             	mov    0xc(%ebp),%eax
    126c:	0f b6 10             	movzbl (%eax),%edx
    126f:	84 d2                	test   %dl,%dl
    1271:	0f 84 c9 00 00 00    	je     1340 <printf+0xe0>
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
    1277:	8d 4d 10             	lea    0x10(%ebp),%ecx
    127a:	31 ff                	xor    %edi,%edi
    127c:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
    127f:	31 db                	xor    %ebx,%ebx
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
    1281:	8d 75 e7             	lea    -0x19(%ebp),%esi
    1284:	eb 1e                	jmp    12a4 <printf+0x44>
    1286:	66 90                	xchg   %ax,%ax
  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
    1288:	83 fa 25             	cmp    $0x25,%edx
    128b:	0f 85 b7 00 00 00    	jne    1348 <printf+0xe8>
    1291:	66 bf 25 00          	mov    $0x25,%di
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    1295:	83 c3 01             	add    $0x1,%ebx
    1298:	0f b6 14 18          	movzbl (%eax,%ebx,1),%edx
    129c:	84 d2                	test   %dl,%dl
    129e:	0f 84 9c 00 00 00    	je     1340 <printf+0xe0>
    c = fmt[i] & 0xff;
    if(state == 0){
    12a4:	85 ff                	test   %edi,%edi
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    12a6:	0f b6 d2             	movzbl %dl,%edx
    if(state == 0){
    12a9:	74 dd                	je     1288 <printf+0x28>
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
    12ab:	83 ff 25             	cmp    $0x25,%edi
    12ae:	75 e5                	jne    1295 <printf+0x35>
      if(c == 'd'){
    12b0:	83 fa 64             	cmp    $0x64,%edx
    12b3:	0f 84 57 01 00 00    	je     1410 <printf+0x1b0>
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
    12b9:	83 fa 70             	cmp    $0x70,%edx
    12bc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    12c0:	0f 84 aa 00 00 00    	je     1370 <printf+0x110>
    12c6:	83 fa 78             	cmp    $0x78,%edx
    12c9:	0f 84 a1 00 00 00    	je     1370 <printf+0x110>
        printint(fd, *ap, 16, 0);
        ap++;
      } else if(c == 's'){
    12cf:	83 fa 73             	cmp    $0x73,%edx
    12d2:	0f 84 c0 00 00 00    	je     1398 <printf+0x138>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
    12d8:	83 fa 63             	cmp    $0x63,%edx
    12db:	90                   	nop
    12dc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    12e0:	0f 84 52 01 00 00    	je     1438 <printf+0x1d8>
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
    12e6:	83 fa 25             	cmp    $0x25,%edx
    12e9:	0f 84 f9 00 00 00    	je     13e8 <printf+0x188>
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
    12ef:	8b 4d 08             	mov    0x8(%ebp),%ecx
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    12f2:	83 c3 01             	add    $0x1,%ebx
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
    12f5:	31 ff                	xor    %edi,%edi
    12f7:	89 55 cc             	mov    %edx,-0x34(%ebp)
    12fa:	c6 45 e7 25          	movb   $0x25,-0x19(%ebp)
    12fe:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
    1305:	00 
    1306:	89 0c 24             	mov    %ecx,(%esp)
    1309:	89 74 24 04          	mov    %esi,0x4(%esp)
    130d:	e8 16 fe ff ff       	call   1128 <write>
    1312:	8b 55 cc             	mov    -0x34(%ebp),%edx
    1315:	8b 45 08             	mov    0x8(%ebp),%eax
    1318:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
    131f:	00 
    1320:	89 74 24 04          	mov    %esi,0x4(%esp)
    1324:	88 55 e7             	mov    %dl,-0x19(%ebp)
    1327:	89 04 24             	mov    %eax,(%esp)
    132a:	e8 f9 fd ff ff       	call   1128 <write>
    132f:	8b 45 0c             	mov    0xc(%ebp),%eax
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    1332:	0f b6 14 18          	movzbl (%eax,%ebx,1),%edx
    1336:	84 d2                	test   %dl,%dl
    1338:	0f 85 66 ff ff ff    	jne    12a4 <printf+0x44>
    133e:	66 90                	xchg   %ax,%ax
        putc(fd, c);
      }
      state = 0;
    }
  }
}
    1340:	83 c4 3c             	add    $0x3c,%esp
    1343:	5b                   	pop    %ebx
    1344:	5e                   	pop    %esi
    1345:	5f                   	pop    %edi
    1346:	5d                   	pop    %ebp
    1347:	c3                   	ret    
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
    1348:	8b 45 08             	mov    0x8(%ebp),%eax
  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
    134b:	88 55 e7             	mov    %dl,-0x19(%ebp)
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
    134e:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
    1355:	00 
    1356:	89 74 24 04          	mov    %esi,0x4(%esp)
    135a:	89 04 24             	mov    %eax,(%esp)
    135d:	e8 c6 fd ff ff       	call   1128 <write>
    1362:	8b 45 0c             	mov    0xc(%ebp),%eax
    1365:	e9 2b ff ff ff       	jmp    1295 <printf+0x35>
    136a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
    1370:	8b 45 d4             	mov    -0x2c(%ebp),%eax
    1373:	b9 10 00 00 00       	mov    $0x10,%ecx
        ap++;
    1378:	31 ff                	xor    %edi,%edi
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
    137a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
    1381:	8b 10                	mov    (%eax),%edx
    1383:	8b 45 08             	mov    0x8(%ebp),%eax
    1386:	e8 35 fe ff ff       	call   11c0 <printint>
    138b:	8b 45 0c             	mov    0xc(%ebp),%eax
        ap++;
    138e:	83 45 d4 04          	addl   $0x4,-0x2c(%ebp)
    1392:	e9 fe fe ff ff       	jmp    1295 <printf+0x35>
    1397:	90                   	nop
      } else if(c == 's'){
        s = (char*)*ap;
    1398:	8b 55 d4             	mov    -0x2c(%ebp),%edx
    139b:	8b 3a                	mov    (%edx),%edi
        ap++;
    139d:	83 c2 04             	add    $0x4,%edx
    13a0:	89 55 d4             	mov    %edx,-0x2c(%ebp)
        if(s == 0)
    13a3:	85 ff                	test   %edi,%edi
    13a5:	0f 84 ba 00 00 00    	je     1465 <printf+0x205>
          s = "(null)";
        while(*s != 0){
    13ab:	0f b6 17             	movzbl (%edi),%edx
    13ae:	84 d2                	test   %dl,%dl
    13b0:	74 2d                	je     13df <printf+0x17f>
    13b2:	89 5d d0             	mov    %ebx,-0x30(%ebp)
    13b5:	8b 5d 08             	mov    0x8(%ebp),%ebx
          putc(fd, *s);
          s++;
    13b8:	83 c7 01             	add    $0x1,%edi
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
    13bb:	88 55 e7             	mov    %dl,-0x19(%ebp)
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
    13be:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
    13c5:	00 
    13c6:	89 74 24 04          	mov    %esi,0x4(%esp)
    13ca:	89 1c 24             	mov    %ebx,(%esp)
    13cd:	e8 56 fd ff ff       	call   1128 <write>
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
    13d2:	0f b6 17             	movzbl (%edi),%edx
    13d5:	84 d2                	test   %dl,%dl
    13d7:	75 df                	jne    13b8 <printf+0x158>
    13d9:	8b 5d d0             	mov    -0x30(%ebp),%ebx
    13dc:	8b 45 0c             	mov    0xc(%ebp),%eax
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
    13df:	31 ff                	xor    %edi,%edi
    13e1:	e9 af fe ff ff       	jmp    1295 <printf+0x35>
    13e6:	66 90                	xchg   %ax,%ax
    13e8:	8b 55 08             	mov    0x8(%ebp),%edx
    13eb:	31 ff                	xor    %edi,%edi
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
    13ed:	c6 45 e7 25          	movb   $0x25,-0x19(%ebp)
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
    13f1:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
    13f8:	00 
    13f9:	89 74 24 04          	mov    %esi,0x4(%esp)
    13fd:	89 14 24             	mov    %edx,(%esp)
    1400:	e8 23 fd ff ff       	call   1128 <write>
    1405:	8b 45 0c             	mov    0xc(%ebp),%eax
    1408:	e9 88 fe ff ff       	jmp    1295 <printf+0x35>
    140d:	8d 76 00             	lea    0x0(%esi),%esi
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
    1410:	8b 45 d4             	mov    -0x2c(%ebp),%eax
    1413:	b9 0a 00 00 00       	mov    $0xa,%ecx
        ap++;
    1418:	66 31 ff             	xor    %di,%di
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
    141b:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
    1422:	8b 10                	mov    (%eax),%edx
    1424:	8b 45 08             	mov    0x8(%ebp),%eax
    1427:	e8 94 fd ff ff       	call   11c0 <printint>
    142c:	8b 45 0c             	mov    0xc(%ebp),%eax
        ap++;
    142f:	83 45 d4 04          	addl   $0x4,-0x2c(%ebp)
    1433:	e9 5d fe ff ff       	jmp    1295 <printf+0x35>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
    1438:	8b 4d d4             	mov    -0x2c(%ebp),%ecx
        putc(fd, *ap);
        ap++;
    143b:	31 ff                	xor    %edi,%edi
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
    143d:	8b 01                	mov    (%ecx),%eax
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
    143f:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
    1446:	00 
    1447:	89 74 24 04          	mov    %esi,0x4(%esp)
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
    144b:	88 45 e7             	mov    %al,-0x19(%ebp)
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
    144e:	8b 45 08             	mov    0x8(%ebp),%eax
    1451:	89 04 24             	mov    %eax,(%esp)
    1454:	e8 cf fc ff ff       	call   1128 <write>
    1459:	8b 45 0c             	mov    0xc(%ebp),%eax
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
        ap++;
    145c:	83 45 d4 04          	addl   $0x4,-0x2c(%ebp)
    1460:	e9 30 fe ff ff       	jmp    1295 <printf+0x35>
        printint(fd, *ap, 16, 0);
        ap++;
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
    1465:	bf f0 16 00 00       	mov    $0x16f0,%edi
    146a:	e9 3c ff ff ff       	jmp    13ab <printf+0x14b>
    146f:	90                   	nop

00001470 <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
    1470:	55                   	push   %ebp
  Header *bp, *p;

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    1471:	a1 c8 19 00 00       	mov    0x19c8,%eax
static Header base;
static Header *freep;

void
free(void *ap)
{
    1476:	89 e5                	mov    %esp,%ebp
    1478:	57                   	push   %edi
    1479:	56                   	push   %esi
    147a:	53                   	push   %ebx
    147b:	8b 5d 08             	mov    0x8(%ebp),%ebx
  Header *bp, *p;

  bp = (Header*) ap - 1;
    147e:	8d 4b f8             	lea    -0x8(%ebx),%ecx
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    1481:	39 c8                	cmp    %ecx,%eax
    1483:	73 1d                	jae    14a2 <free+0x32>
    1485:	8d 76 00             	lea    0x0(%esi),%esi
    1488:	8b 10                	mov    (%eax),%edx
    148a:	39 d1                	cmp    %edx,%ecx
    148c:	72 1a                	jb     14a8 <free+0x38>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
    148e:	39 d0                	cmp    %edx,%eax
    1490:	72 08                	jb     149a <free+0x2a>
    1492:	39 c8                	cmp    %ecx,%eax
    1494:	72 12                	jb     14a8 <free+0x38>
    1496:	39 d1                	cmp    %edx,%ecx
    1498:	72 0e                	jb     14a8 <free+0x38>
    149a:	89 d0                	mov    %edx,%eax
free(void *ap)
{
  Header *bp, *p;

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    149c:	39 c8                	cmp    %ecx,%eax
    149e:	66 90                	xchg   %ax,%ax
    14a0:	72 e6                	jb     1488 <free+0x18>
    14a2:	8b 10                	mov    (%eax),%edx
    14a4:	eb e8                	jmp    148e <free+0x1e>
    14a6:	66 90                	xchg   %ax,%ax
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    14a8:	8b 71 04             	mov    0x4(%ecx),%esi
    14ab:	8d 3c f1             	lea    (%ecx,%esi,8),%edi
    14ae:	39 d7                	cmp    %edx,%edi
    14b0:	74 19                	je     14cb <free+0x5b>
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
    14b2:	89 53 f8             	mov    %edx,-0x8(%ebx)
  if(p + p->s.size == bp){
    14b5:	8b 50 04             	mov    0x4(%eax),%edx
    14b8:	8d 34 d0             	lea    (%eax,%edx,8),%esi
    14bb:	39 ce                	cmp    %ecx,%esi
    14bd:	74 23                	je     14e2 <free+0x72>
    p->s.size += bp->s.size;
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
    14bf:	89 08                	mov    %ecx,(%eax)
  freep = p;
    14c1:	a3 c8 19 00 00       	mov    %eax,0x19c8
}
    14c6:	5b                   	pop    %ebx
    14c7:	5e                   	pop    %esi
    14c8:	5f                   	pop    %edi
    14c9:	5d                   	pop    %ebp
    14ca:	c3                   	ret    
  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
    14cb:	03 72 04             	add    0x4(%edx),%esi
    14ce:	89 71 04             	mov    %esi,0x4(%ecx)
    bp->s.ptr = p->s.ptr->s.ptr;
    14d1:	8b 10                	mov    (%eax),%edx
    14d3:	8b 12                	mov    (%edx),%edx
    14d5:	89 53 f8             	mov    %edx,-0x8(%ebx)
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    14d8:	8b 50 04             	mov    0x4(%eax),%edx
    14db:	8d 34 d0             	lea    (%eax,%edx,8),%esi
    14de:	39 ce                	cmp    %ecx,%esi
    14e0:	75 dd                	jne    14bf <free+0x4f>
    p->s.size += bp->s.size;
    14e2:	03 51 04             	add    0x4(%ecx),%edx
    14e5:	89 50 04             	mov    %edx,0x4(%eax)
    p->s.ptr = bp->s.ptr;
    14e8:	8b 53 f8             	mov    -0x8(%ebx),%edx
    14eb:	89 10                	mov    %edx,(%eax)
  } else
    p->s.ptr = bp;
  freep = p;
    14ed:	a3 c8 19 00 00       	mov    %eax,0x19c8
}
    14f2:	5b                   	pop    %ebx
    14f3:	5e                   	pop    %esi
    14f4:	5f                   	pop    %edi
    14f5:	5d                   	pop    %ebp
    14f6:	c3                   	ret    
    14f7:	89 f6                	mov    %esi,%esi
    14f9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00001500 <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
    1500:	55                   	push   %ebp
    1501:	89 e5                	mov    %esp,%ebp
    1503:	57                   	push   %edi
    1504:	56                   	push   %esi
    1505:	53                   	push   %ebx
    1506:	83 ec 1c             	sub    $0x1c,%esp
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
    1509:	8b 5d 08             	mov    0x8(%ebp),%ebx
  if((prevp = freep) == 0){
    150c:	8b 0d c8 19 00 00    	mov    0x19c8,%ecx
malloc(uint nbytes)
{
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
    1512:	83 c3 07             	add    $0x7,%ebx
    1515:	c1 eb 03             	shr    $0x3,%ebx
    1518:	83 c3 01             	add    $0x1,%ebx
  if((prevp = freep) == 0){
    151b:	85 c9                	test   %ecx,%ecx
    151d:	0f 84 93 00 00 00    	je     15b6 <malloc+0xb6>
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    1523:	8b 01                	mov    (%ecx),%eax
    if(p->s.size >= nunits){
    1525:	8b 50 04             	mov    0x4(%eax),%edx
    1528:	39 d3                	cmp    %edx,%ebx
    152a:	76 1f                	jbe    154b <malloc+0x4b>
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
    152c:	8d 34 dd 00 00 00 00 	lea    0x0(,%ebx,8),%esi
    1533:	90                   	nop
    1534:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    }
    if(p == freep)
    1538:	3b 05 c8 19 00 00    	cmp    0x19c8,%eax
    153e:	74 30                	je     1570 <malloc+0x70>
    1540:	89 c1                	mov    %eax,%ecx
  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    1542:	8b 01                	mov    (%ecx),%eax
    if(p->s.size >= nunits){
    1544:	8b 50 04             	mov    0x4(%eax),%edx
    1547:	39 d3                	cmp    %edx,%ebx
    1549:	77 ed                	ja     1538 <malloc+0x38>
      if(p->s.size == nunits)
    154b:	39 d3                	cmp    %edx,%ebx
    154d:	74 61                	je     15b0 <malloc+0xb0>
        prevp->s.ptr = p->s.ptr;
      else {
        p->s.size -= nunits;
    154f:	29 da                	sub    %ebx,%edx
    1551:	89 50 04             	mov    %edx,0x4(%eax)
        p += p->s.size;
    1554:	8d 04 d0             	lea    (%eax,%edx,8),%eax
        p->s.size = nunits;
    1557:	89 58 04             	mov    %ebx,0x4(%eax)
      }
      freep = prevp;
    155a:	89 0d c8 19 00 00    	mov    %ecx,0x19c8
      return (void*) (p + 1);
    1560:	83 c0 08             	add    $0x8,%eax
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
    1563:	83 c4 1c             	add    $0x1c,%esp
    1566:	5b                   	pop    %ebx
    1567:	5e                   	pop    %esi
    1568:	5f                   	pop    %edi
    1569:	5d                   	pop    %ebp
    156a:	c3                   	ret    
    156b:	90                   	nop
    156c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < 4096)
    1570:	81 fb ff 0f 00 00    	cmp    $0xfff,%ebx
    1576:	b8 00 80 00 00       	mov    $0x8000,%eax
    157b:	bf 00 10 00 00       	mov    $0x1000,%edi
    1580:	76 04                	jbe    1586 <malloc+0x86>
    1582:	89 f0                	mov    %esi,%eax
    1584:	89 df                	mov    %ebx,%edi
    nu = 4096;
  p = sbrk(nu * sizeof(Header));
    1586:	89 04 24             	mov    %eax,(%esp)
    1589:	e8 02 fc ff ff       	call   1190 <sbrk>
  if(p == (char*) -1)
    158e:	83 f8 ff             	cmp    $0xffffffff,%eax
    1591:	74 18                	je     15ab <malloc+0xab>
    return 0;
  hp = (Header*)p;
  hp->s.size = nu;
    1593:	89 78 04             	mov    %edi,0x4(%eax)
  free((void*)(hp + 1));
    1596:	83 c0 08             	add    $0x8,%eax
    1599:	89 04 24             	mov    %eax,(%esp)
    159c:	e8 cf fe ff ff       	call   1470 <free>
  return freep;
    15a1:	8b 0d c8 19 00 00    	mov    0x19c8,%ecx
      }
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
    15a7:	85 c9                	test   %ecx,%ecx
    15a9:	75 97                	jne    1542 <malloc+0x42>
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
    15ab:	31 c0                	xor    %eax,%eax
    15ad:	eb b4                	jmp    1563 <malloc+0x63>
    15af:	90                   	nop
      if(p->s.size == nunits)
        prevp->s.ptr = p->s.ptr;
    15b0:	8b 10                	mov    (%eax),%edx
    15b2:	89 11                	mov    %edx,(%ecx)
    15b4:	eb a4                	jmp    155a <malloc+0x5a>
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    15b6:	c7 05 c8 19 00 00 c0 	movl   $0x19c0,0x19c8
    15bd:	19 00 00 
    base.s.size = 0;
    15c0:	b9 c0 19 00 00       	mov    $0x19c0,%ecx
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    15c5:	c7 05 c0 19 00 00 c0 	movl   $0x19c0,0x19c0
    15cc:	19 00 00 
    base.s.size = 0;
    15cf:	c7 05 c4 19 00 00 00 	movl   $0x0,0x19c4
    15d6:	00 00 00 
    15d9:	e9 45 ff ff ff       	jmp    1523 <malloc+0x23>
